use of io.lettuce.core.RedisURI in project verify-hub by alphagov.
the class PolicyAppExtension method getSessionState.
public static <T extends State> T getSessionState(SessionId sessionId, Class<T> stateClazz) {
StatefulRedisConnection<SessionId, State> redisConnection = RedisClient.create().connect(new SessionStoreRedisCodec(PolicyModule.getRedisObjectMapper()), new RedisURI("localhost", REDIS_PORT, Duration.ofSeconds(2)));
RedisSessionStore redisSessionStore = new RedisSessionStore(redisConnection.sync(), 3600L);
return stateClazz.cast(redisSessionStore.get(sessionId));
}
use of io.lettuce.core.RedisURI in project verify-hub by alphagov.
the class SamlEngineModule method getIdExpirationCache.
private <T> IdExpirationCache<T> getIdExpirationCache(RedisConfiguration config, RedisCodec<T, DateTime> codec, int dbIndex) {
RedisClient redisClient = RedisClient.create();
redisClient.setDefaultTimeout(config.getTimeout());
RedisURI uri = config.getUri();
uri.setDatabase(dbIndex);
StatefulRedisMasterSlaveConnection<T, DateTime> redisConnection = MasterSlave.connect(redisClient, codec, singletonList(uri));
RedisCommands<T, DateTime> redisCommands = redisConnection.sync();
return new RedisIdExpirationCache<>(redisCommands, config.getRecordTTL());
}
use of io.lettuce.core.RedisURI in project jetcache by alibaba.
the class LettuceConnectionManagerTest method testCluster.
@Test
public void testCluster() {
if (!RedisLettuceCacheTest.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));
LettuceConnectionManager m = LettuceConnectionManager.defaultManager();
m.init(client, null);
Assert.assertSame(m.commands(client), m.commands(client));
Assert.assertSame(m.asyncCommands(client), m.asyncCommands(client));
Assert.assertSame(m.reactiveCommands(client), m.reactiveCommands(client));
m.removeAndClose(client);
}
use of io.lettuce.core.RedisURI in project jetcache by alibaba.
the class RedisLettuceCacheTest method testCluster.
@Test
public void testCluster() 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));
test(client, null);
}
use of io.lettuce.core.RedisURI in project pinpoint by naver.
the class RedisClientConstructorInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
if (!validate(target, args)) {
return;
}
final RedisURI redisURI = (RedisURI) args[1];
final String endPoint = HostAndPort.toHostAndPortString(redisURI.getHost(), redisURI.getPort());
((EndPointAccessor) target)._$PINPOINT$_setEndPoint(endPoint);
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
}
Aggregations