use of io.lettuce.core.masterslave.StatefulRedisMasterSlaveConnection in project jetcache by alibaba.
the class RedisLettuceCacheTest method testSentinel2.
@Test
public void testSentinel2() 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();
StatefulRedisMasterSlaveConnection con = MasterSlave.connect(client, new JetCacheCodec(), redisUri);
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