Search in sources :

Example 11 with RedisClient

use of io.lettuce.core.RedisClient in project jetcache by alibaba.

the class RedisLettuceCacheTest method testWithMultiLevelCache.

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

Aggregations

RedisClient (io.lettuce.core.RedisClient)11 Test (org.junit.Test)6 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)4 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)4 AbstractRedisClient (io.lettuce.core.AbstractRedisClient)4 RedisURI (io.lettuce.core.RedisURI)3 Random (java.util.Random)3 StatefulRedisConnection (io.lettuce.core.api.StatefulRedisConnection)2 RedisAsyncCommands (io.lettuce.core.api.async.RedisAsyncCommands)2 Cache (com.alicp.jetcache.Cache)1 RedisLettuceCacheTest (com.alicp.jetcache.redis.lettuce.RedisLettuceCacheTest)1 SpringTest (com.alicp.jetcache.test.spring.SpringTest)1 RedisReactiveCommands (io.lettuce.core.api.reactive.RedisReactiveCommands)1 RedisCommands (io.lettuce.core.api.sync.RedisCommands)1 RedisClusterClient (io.lettuce.core.cluster.RedisClusterClient)1 RedisClusterAsyncCommands (io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands)1 RedisClusterReactiveCommands (io.lettuce.core.cluster.api.reactive.RedisClusterReactiveCommands)1 RedisClusterCommands (io.lettuce.core.cluster.api.sync.RedisClusterCommands)1 StatefulRedisMasterSlaveConnection (io.lettuce.core.masterslave.StatefulRedisMasterSlaveConnection)1 DateTime (org.joda.time.DateTime)1