• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StatefulRedisConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.lettuce.core.api.StatefulRedisConnection的典型用法代码示例。如果您正苦于以下问题:Java StatefulRedisConnection类的具体用法?Java StatefulRedisConnection怎么用?Java StatefulRedisConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StatefulRedisConnection类属于io.lettuce.core.api包,在下文中一共展示了StatefulRedisConnection类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sync

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@Test
public void sync() {
  RedisClient client = RedisClient.create("redis://localhost");

  StatefulRedisConnection<String, String> connection =
      new TracingStatefulRedisConnection<>(client.connect(), mockTracer, false);
  RedisCommands<String, String> commands = connection.sync();

  assertEquals("OK", commands.set("key", "value"));
  assertEquals("value", commands.get("key"));

  connection.close();

  client.shutdown();

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:19,代码来源:TracingLettuceTest.java


示例2: commands

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public Object commands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.commands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.commands = ((StatefulRedisConnection) lo.connection).sync();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.commands = ((StatefulRedisClusterConnection) lo.connection).sync();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.commands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java


示例3: asyncCommands

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public Object asyncCommands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.asyncCommands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.asyncCommands = ((StatefulRedisConnection) lo.connection).async();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.asyncCommands = ((StatefulRedisClusterConnection) lo.connection).async();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.asyncCommands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java


示例4: reactiveCommands

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public Object reactiveCommands(AbstractRedisClient redisClient) {
    connection(redisClient);
    LettuceObjects lo = getLettuceObjectsFromMap(redisClient);
    if (lo.reactiveCommands == null) {
        if (lo.connection instanceof StatefulRedisConnection) {
            lo.reactiveCommands = ((StatefulRedisConnection) lo.connection).reactive();
        } else if (lo.connection instanceof StatefulRedisClusterConnection) {
            lo.reactiveCommands = ((StatefulRedisClusterConnection) lo.connection).reactive();
        } else {
            throw new CacheConfigException("type " + lo.connection.getClass() + " is not supported");
        }
    }
    return lo.reactiveCommands;
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:15,代码来源:LettuceConnectionManager.java


示例5: tests

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@Test
public void tests() throws Exception {
    if (RedisLettuceCacheTest.checkOS()) {
        System.setProperty("spring.profiles.active", "redislettuce-cluster");
    } else {
        System.setProperty("spring.profiles.active", "redislettuce");
    }
    context = SpringApplication.run(RedisLettuceStarterTest.class);
    doTest();
    A bean = context.getBean(A.class);
    bean.test();

    RedisClient t1 = (RedisClient) context.getBean("defaultClient");
    RedisClient t2 = (RedisClient) context.getBean("a1Client");
    Assert.assertNotNull(t1);
    Assert.assertNotNull(t2);
    Assert.assertNotSame(t1, t2);

    AutoConfigureBeans acb = context.getBean(AutoConfigureBeans.class);

    String key = "remote.A1";
    Assert.assertTrue(new LettuceFactory(acb, key, StatefulRedisConnection.class).getObject() instanceof StatefulRedisConnection);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisCommands.class).getObject() instanceof RedisCommands);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisAsyncCommands.class).getObject() instanceof RedisAsyncCommands);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisReactiveCommands.class).getObject() instanceof RedisReactiveCommands);

    if (RedisLettuceCacheTest.checkOS()) {
        key = "remote.A2";
        Assert.assertTrue(new LettuceFactory(acb, key , RedisClusterClient.class).getObject() instanceof RedisClusterClient);
        Assert.assertTrue(new LettuceFactory(acb, key , RedisClusterCommands.class).getObject() instanceof RedisClusterCommands);
        Assert.assertTrue(new LettuceFactory(acb, key , RedisClusterAsyncCommands.class).getObject() instanceof RedisClusterAsyncCommands);
        Assert.assertTrue(new LettuceFactory(acb, key , RedisClusterReactiveCommands.class).getObject() instanceof RedisClusterReactiveCommands);
    }
}
 
开发者ID:alibaba,项目名称:jetcache,代码行数:35,代码来源:RedisLettuceStarterTest.java


示例6: TracingStatefulRedisConnection

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
/**
 * @param connection redis connection
 * @param tracer tracer
 * @param traceWithActiveSpanOnly if <code>true</code> then create new spans only if there is
 * active span
 */
public TracingStatefulRedisConnection(StatefulRedisConnection<K, V> connection, Tracer tracer,
    boolean traceWithActiveSpanOnly) {
  this.connection = connection;
  this.tracer = tracer;
  this.traceWithActiveSpanOnly = traceWithActiveSpanOnly;
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:13,代码来源:TracingStatefulRedisConnection.java


示例7: run

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@Override
public void run(Configuration configuration, Environment environment) {

    environment.jersey().register(new LoginResource());
    environment.jersey().register(new UserResource());

    environment.jersey().register(new AuthDynamicFeature(
            new OAuthCredentialAuthFilter.Builder<PrincipalImpl>()
                    .setAuthenticator(new TestOAuthAuthenticator()).setPrefix("Bearer")
                    .buildAuthFilter()));
    environment.jersey().register(RolesAllowedDynamicFeature.class);
    environment.jersey().register(new AuthValueFactoryProvider.Binder<>(PrincipalImpl.class));

    //TODO move this cleanup into the tests
    environment.lifecycle().manage(new Managed() {
        @Override
        public void start() {
        }

        @Override
        public void stop() {
            flushRedis();
        }

        private void flushRedis() {
            try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {
                connection.sync().flushdb();
            }
            redisClient.shutdownAsync();
        }
    });

}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:34,代码来源:RateLimitApplication.java


示例8: RedisSlidingWindowRequestRateLimiter

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public RedisSlidingWindowRequestRateLimiter(StatefulRedisConnection<String, String> connection, Set<RequestLimitRule> rules, TimeSupplier timeSupplier) {
    requireNonNull(rules, "rules can not be null");
    requireNonNull(timeSupplier, "time supplier can not be null");
    requireNonNull(connection, "connection can not be null");
    this.connection = connection;
    scriptLoader = new RedisScriptLoader(connection, "sliding-window-ratelimit.lua");
    rulesJson = serialiserLimitRules(rules);
    this.timeSupplier = timeSupplier;
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:10,代码来源:RedisSlidingWindowRequestRateLimiter.java


示例9: RedisScriptLoader

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public RedisScriptLoader(StatefulRedisConnection<String, String> connection, String scriptUri, boolean eagerLoad) {
    requireNonNull(connection);
    this.connection = connection;
    this.scriptUri = requireNonNull(scriptUri);
    if (eagerLoad) {
        scriptSha();
    }
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:9,代码来源:RedisScriptLoader.java


示例10: getConnection

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
private StatefulRedisConnection<String, String> getConnection() {
    // going to ignore race conditions at the cost of having multiple connections
    if (connection == null) {
        connection = client.connect();
    }
    return connection;
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:8,代码来源:RedisRateLimiterFactory.java


示例11: getStatefulConnection

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@Override
public StatefulRedisConnection<K, V> getStatefulConnection() {
  return new TracingStatefulRedisConnection<>(commands.getStatefulConnection(), tracer,
      traceWithActiveSpanOnly);
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:6,代码来源:TracingRedisCommands.java


示例12: async

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@Test
public void async() throws Exception {
  RedisClient client = RedisClient.create("redis://localhost");

  StatefulRedisConnection<String, String> connection =
      new TracingStatefulRedisConnection<>(client.connect(), mockTracer, false);

  RedisAsyncCommands<String, String> commands = connection.async();

  assertEquals("OK", commands.set("key2", "value2").get(15, TimeUnit.SECONDS));

  assertEquals("value2", commands.get("key2").get(15, TimeUnit.SECONDS));

  connection.close();

  client.shutdown();

  List<MockSpan> spans = mockTracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
开发者ID:opentracing-contrib,项目名称:java-redis-client,代码行数:21,代码来源:TracingLettuceTest.java


示例13: RedisTimeSupplier

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
public RedisTimeSupplier(StatefulRedisConnection<String, String> connection) {
    this.connection = requireNonNull(connection);
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:4,代码来源:RedisTimeSupplier.java


示例14: afterEach

import io.lettuce.core.api.StatefulRedisConnection; //导入依赖的package包/类
@AfterEach
void afterEach() {
    try (StatefulRedisConnection<String, String> connection = client.connect()) {
        connection.sync().flushdb();
    }
}
 
开发者ID:mokies,项目名称:ratelimitj,代码行数:7,代码来源:RedisSlidingWindowSyncRequestRateLimiterTest.java



注:本文中的io.lettuce.core.api.StatefulRedisConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexModel类代码示例发布时间:2022-05-22
下一篇:
Java Application类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap