Search in sources :

Example 1 with RedisClient

use of com.lambdaworks.redis.RedisClient in project jetcache by alibaba.

the class LutteceConnectionManagerTest method test.

@Test
public void test() {
    RedisClient client = RedisClient.create("redis://127.0.0.1");
    LutteceConnectionManager m = LutteceConnectionManager.defaultManager();
    Assert.assertSame(m.commands(client), m.commands(client));
    Assert.assertSame(m.asyncCommands(client), m.asyncCommands(client));
    Assert.assertSame(m.reactiveCommands(client), m.reactiveCommands(client));
    m.removeAndClose(client);
}
Also used : RedisClient(com.lambdaworks.redis.RedisClient) Test(org.junit.Test)

Example 2 with RedisClient

use of com.lambdaworks.redis.RedisClient in project ud381 by udacity.

the class ReportBolt method prepare.

@Override
public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
    // instantiate a redis connection
    RedisClient client = new RedisClient("localhost", 6379);
    URLCounter = new HashMap<String, Integer>();
    sentimentURL = new HashMap<String, Double>();
    // initiate the actual connection
    redis = client.connect();
}
Also used : RedisClient(com.lambdaworks.redis.RedisClient)

Example 3 with RedisClient

use of com.lambdaworks.redis.RedisClient in project jetcache by alibaba.

the class RedisLutteceStarterTest method tests.

@Test
public void tests() throws Exception {
    if (RedisLutteceCacheTest.checkOS()) {
        System.setProperty("spring.profiles.active", "redisluttece-cluster");
    } else {
        System.setProperty("spring.profiles.active", "redisluttece");
    }
    context = SpringApplication.run(RedisLutteceStarterTest.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 LutteceFactory(acb, key, StatefulRedisConnection.class).getObject() instanceof StatefulRedisConnection);
    Assert.assertTrue(new LutteceFactory(acb, key, RedisCommands.class).getObject() instanceof RedisCommands);
    Assert.assertTrue(new LutteceFactory(acb, key, RedisAsyncCommands.class).getObject() instanceof RedisAsyncCommands);
    Assert.assertTrue(new LutteceFactory(acb, key, RedisReactiveCommands.class).getObject() instanceof RedisReactiveCommands);
    if (RedisLutteceCacheTest.checkOS()) {
        key = "remote.A2";
        Assert.assertTrue(new LutteceFactory(acb, key, RedisClusterClient.class).getObject() instanceof RedisClusterClient);
        Assert.assertTrue(new LutteceFactory(acb, key, RedisClusterCommands.class).getObject() instanceof RedisClusterCommands);
        Assert.assertTrue(new LutteceFactory(acb, key, RedisClusterAsyncCommands.class).getObject() instanceof RedisClusterAsyncCommands);
        Assert.assertTrue(new LutteceFactory(acb, key, RedisClusterReactiveCommands.class).getObject() instanceof RedisClusterReactiveCommands);
    }
}
Also used : RedisClusterCommands(com.lambdaworks.redis.cluster.api.sync.RedisClusterCommands) StatefulRedisConnection(com.lambdaworks.redis.api.StatefulRedisConnection) RedisClusterAsyncCommands(com.lambdaworks.redis.cluster.api.async.RedisClusterAsyncCommands) RedisClient(com.lambdaworks.redis.RedisClient) RedisCommands(com.lambdaworks.redis.api.sync.RedisCommands) RedisAsyncCommands(com.lambdaworks.redis.api.async.RedisAsyncCommands) RedisClusterReactiveCommands(com.lambdaworks.redis.cluster.api.rx.RedisClusterReactiveCommands) RedisClusterClient(com.lambdaworks.redis.cluster.RedisClusterClient) RedisReactiveCommands(com.lambdaworks.redis.api.rx.RedisReactiveCommands) SpringTest(com.alicp.jetcache.test.spring.SpringTest) Test(org.junit.Test) RedisLutteceCacheTest(com.alicp.jetcache.redis.luttece.RedisLutteceCacheTest)

Example 4 with RedisClient

use of com.lambdaworks.redis.RedisClient in project jetcache by alibaba.

the class RedisLutteceCacheTest method testSentinel.

@Test
public void testSentinel() throws Exception {
    RedisURI redisUri = RedisURI.Builder.sentinel("127.0.0.1", 26379, "mymaster").withSentinel("127.0.0.1", 26380).withSentinel("127.0.0.1", 26381).build();
    RedisClient client = RedisClient.create(redisUri);
    test(client);
}
Also used : AbstractRedisClient(com.lambdaworks.redis.AbstractRedisClient) RedisClient(com.lambdaworks.redis.RedisClient) RedisURI(com.lambdaworks.redis.RedisURI) RefreshCacheTest(com.alicp.jetcache.RefreshCacheTest) Test(org.junit.Test) LoadingCacheTest(com.alicp.jetcache.LoadingCacheTest) AbstractExternalCacheTest(com.alicp.jetcache.test.external.AbstractExternalCacheTest)

Example 5 with RedisClient

use of com.lambdaworks.redis.RedisClient in project jetcache by alibaba.

the class RedisLutteceCacheTest method testWithMultiLevelCache.

@Test
public void testWithMultiLevelCache() throws Exception {
    Cache l1Cache = CaffeineCacheBuilder.createCaffeineCacheBuilder().limit(10).expireAfterWrite(100, TimeUnit.MILLISECONDS).keyConvertor(FastjsonKeyConvertor.INSTANCE).buildCache();
    RedisClient client = RedisClient.create("redis://127.0.0.1");
    Cache l2Cache = RedisLutteceCacheBuilder.createRedisLutteceCacheBuilder().redisClient(client).keyConvertor(FastjsonKeyConvertor.INSTANCE).valueEncoder(JavaValueEncoder.INSTANCE).valueDecoder(JavaValueDecoder.INSTANCE).keyPrefix(new Random().nextInt() + "").expireAfterWrite(100, TimeUnit.MILLISECONDS).buildCache();
    cache = MultiLevelCacheBuilder.createMultiLevelCacheBuilder().expireAfterWrite(100, TimeUnit.MILLISECONDS).addCache(l1Cache, l2Cache).buildCache();
    baseTest();
    expireAfterWriteTest(100);
    LoadingCacheTest.loadingCacheTest(MultiLevelCacheBuilder.createMultiLevelCacheBuilder().expireAfterWrite(5000, TimeUnit.MILLISECONDS).addCache(l1Cache, l2Cache), 50);
}
Also used : AbstractRedisClient(com.lambdaworks.redis.AbstractRedisClient) RedisClient(com.lambdaworks.redis.RedisClient) Random(java.util.Random) Cache(com.alicp.jetcache.Cache) RefreshCacheTest(com.alicp.jetcache.RefreshCacheTest) Test(org.junit.Test) LoadingCacheTest(com.alicp.jetcache.LoadingCacheTest) AbstractExternalCacheTest(com.alicp.jetcache.test.external.AbstractExternalCacheTest)

Aggregations

RedisClient (com.lambdaworks.redis.RedisClient)6 Test (org.junit.Test)5 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)3 RefreshCacheTest (com.alicp.jetcache.RefreshCacheTest)3 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)3 AbstractRedisClient (com.lambdaworks.redis.AbstractRedisClient)3 Cache (com.alicp.jetcache.Cache)1 RedisLutteceCacheTest (com.alicp.jetcache.redis.luttece.RedisLutteceCacheTest)1 SpringTest (com.alicp.jetcache.test.spring.SpringTest)1 RedisURI (com.lambdaworks.redis.RedisURI)1 StatefulRedisConnection (com.lambdaworks.redis.api.StatefulRedisConnection)1 RedisAsyncCommands (com.lambdaworks.redis.api.async.RedisAsyncCommands)1 RedisReactiveCommands (com.lambdaworks.redis.api.rx.RedisReactiveCommands)1 RedisCommands (com.lambdaworks.redis.api.sync.RedisCommands)1 RedisClusterClient (com.lambdaworks.redis.cluster.RedisClusterClient)1 RedisClusterAsyncCommands (com.lambdaworks.redis.cluster.api.async.RedisClusterAsyncCommands)1 RedisClusterReactiveCommands (com.lambdaworks.redis.cluster.api.rx.RedisClusterReactiveCommands)1 RedisClusterCommands (com.lambdaworks.redis.cluster.api.sync.RedisClusterCommands)1 Random (java.util.Random)1