use of io.lettuce.core.RedisURI 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"));
}
use of io.lettuce.core.RedisURI 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"));
}
use of io.lettuce.core.RedisURI in project jetcache by alibaba.
the class RedisLettuceCacheTest method testSentinel.
@Test
public void testSentinel() 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(redisUri);
test(client, null);
}
use of io.lettuce.core.RedisURI in project pinpoint by naver.
the class RedisClusterClientConstructorInterceptor method getEndPoint.
private String getEndPoint(Iterable<RedisURI> redisURIs) {
final List<String> endPoints = new ArrayList<>();
for (RedisURI redisURI : redisURIs) {
final String hostAndPort = HostAndPort.toHostAndPortString(redisURI.getHost(), redisURI.getPort());
endPoints.add(hostAndPort);
}
return endPoints.isEmpty() ? null : endPoints.toString();
}
use of io.lettuce.core.RedisURI in project verify-hub by alphagov.
the class PolicyConfigurationBuilder method build.
public PolicyConfiguration build() {
SessionStoreConfiguration sessionStoreConfiguration = mock(SessionStoreConfiguration.class);
when(sessionStoreConfiguration.getRedisConfiguration()).thenReturn(new RedisConfiguration() {
@Override
public Long getRecordTTL() {
return 3600L;
}
@Override
public RedisURI getUri() {
return new RedisURI("localhost", redisPort, java.time.Duration.ofSeconds(1));
}
});
return new TestPolicyConfiguration(new JerseyClientConfiguration(), serviceInfo, mock(ClientTrustStoreConfiguration.class), sessionStoreConfiguration, timeoutPeriod, Duration.minutes(1), Duration.minutes(15));
}
Aggregations