use of io.lettuce.core.cluster.api.StatefulRedisClusterConnection in project jetcache by alibaba.
the class RedisLettuceCacheTest method testCluster2.
@Test
public void testCluster2() throws Exception {
if (!checkOS()) {
return;
}
RedisURI node1 = RedisURI.create("127.0.0.1", 7000);
RedisURI node2 = RedisURI.create("127.0.0.1", 7001);
RedisURI node3 = RedisURI.create("127.0.0.1", 7002);
RedisClusterClient client = RedisClusterClient.create(Arrays.asList(node1, node2, node3));
StatefulRedisClusterConnection con = client.connect(new JetCacheCodec());
con.setReadFrom(ReadFrom.SLAVE_PREFERRED);
cache = RedisLettuceCacheBuilder.createRedisLettuceCacheBuilder().redisClient(client).connection(con).keyPrefix(new Random().nextInt() + "").buildCache();
cache.put("K1", "V1");
Thread.sleep(100);
Assert.assertEquals("V1", cache.get("K1"));
}
Aggregations