use of com.lcache.extend.handle.redis.lettuce.config.LettuceConnectSourceConfig in project lcache by long172066912.
the class TestRedisCache2 method asyncTest.
@Test
public void asyncTest() {
BaseCacheExecutor baseCacheExecutor = CacheClientFactory.getCacheExecutor("test", new LettuceConnectSourceConfig());
baseCacheExecutor.del("lincr1");
baseCacheExecutor.async().incr("lincr1", 60).thenRun(() -> baseCacheExecutor.asyncL().incr("lincr1"));
assertEquals(2, Long.parseLong(baseCacheExecutor.get("lincr1")));
System.out.println("asyncIncr 通过 !");
baseCacheExecutor.set("test", "aaa", 60);
baseCacheExecutor.asyncL().getset("test", "bbb").thenRun(() -> baseCacheExecutor.asyncL().getset("test", "ccc").thenRun(() -> assertEquals("ccc", baseCacheExecutor.get("test"))));
System.out.println("asyncTest 通过 !");
}
use of com.lcache.extend.handle.redis.lettuce.config.LettuceConnectSourceConfig in project lcache by long172066912.
the class TestRedisCache2 method evalZadd.
@Test
public void evalZadd() {
new Thread(() -> {
BaseCacheExecutor jedis = CacheClientFactory.getCacheExecutor(CacheConfigModel.jedisPool("test"), new JedisConnectSourceConfig());
// zset批量判断是否存
String jzsetKey = "jzset:test:1";
jedis.del(jzsetKey);
while (true) {
try {
jedis.zadd(jzsetKey, ImmutableMap.of("a", (double) 1, "b", (double) 2, "c", (double) 3), 3600);
jedis.zaddIfKeyExists(jzsetKey, 4, "e", 3600);
Map<String, Double> score = jedis.zscoreBatch(jzsetKey, Arrays.asList("a", "b", "c", "e"));
System.out.println("jedis : " + JSON.toJSONString(score));
Thread.sleep(500L);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
BaseCacheExecutor baseCacheExecutor = CacheClientFactory.getCacheExecutor("test", new LettuceConnectSourceConfig());
// zset批量判断是否存
String zsetKey = "lzset:test:1";
baseCacheExecutor.del(zsetKey);
while (true) {
try {
baseCacheExecutor.zadd(zsetKey, ImmutableMap.of("a", (double) 1, "b", (double) 2, "c", (double) 3), 3600);
baseCacheExecutor.zaddIfKeyExists(zsetKey, 4, "e", 3600);
Map<String, Double> score = baseCacheExecutor.zscoreBatch(zsetKey, Arrays.asList("a", "b", "c", "e"));
System.out.println("lettuce : " + JSON.toJSONString(score));
Thread.sleep(500L);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations