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);
}
Aggregations