Search in sources :

Example 6 with RedisURI

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));
}
Also used : State(uk.gov.ida.hub.policy.domain.State) SessionStoreRedisCodec(uk.gov.ida.hub.policy.redis.SessionStoreRedisCodec) RedisURI(io.lettuce.core.RedisURI) SessionId(uk.gov.ida.hub.policy.domain.SessionId) RedisSessionStore(uk.gov.ida.hub.policy.session.RedisSessionStore)

Example 7 with RedisURI

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());
}
Also used : RedisClient(io.lettuce.core.RedisClient) RedisURI(io.lettuce.core.RedisURI) RedisIdExpirationCache(uk.gov.ida.hub.samlengine.security.RedisIdExpirationCache) DateTime(org.joda.time.DateTime)

Example 8 with RedisURI

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);
}
Also used : RedisURI(io.lettuce.core.RedisURI) RedisClusterClient(io.lettuce.core.cluster.RedisClusterClient) Test(org.junit.Test)

Example 9 with RedisURI

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);
}
Also used : RedisURI(io.lettuce.core.RedisURI) RedisClusterClient(io.lettuce.core.cluster.RedisClusterClient) LoadingCacheTest(com.alicp.jetcache.LoadingCacheTest) AbstractExternalCacheTest(com.alicp.jetcache.test.external.AbstractExternalCacheTest) Test(org.junit.Test)

Example 10 with RedisURI

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);
        }
    }
}
Also used : EndPointAccessor(com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor) RedisURI(io.lettuce.core.RedisURI)

Aggregations

RedisURI (io.lettuce.core.RedisURI)10 Test (org.junit.Test)5 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)4 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)4 RedisClient (io.lettuce.core.RedisClient)3 RedisClusterClient (io.lettuce.core.cluster.RedisClusterClient)3 AbstractRedisClient (io.lettuce.core.AbstractRedisClient)2 Random (java.util.Random)2 EndPointAccessor (com.navercorp.pinpoint.plugin.redis.lettuce.EndPointAccessor)1 JerseyClientConfiguration (io.dropwizard.client.JerseyClientConfiguration)1 StatefulRedisClusterConnection (io.lettuce.core.cluster.api.StatefulRedisClusterConnection)1 StatefulRedisMasterSlaveConnection (io.lettuce.core.masterslave.StatefulRedisMasterSlaveConnection)1 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 RedisConfiguration (uk.gov.ida.hub.policy.configuration.RedisConfiguration)1 SessionStoreConfiguration (uk.gov.ida.hub.policy.configuration.SessionStoreConfiguration)1 SessionId (uk.gov.ida.hub.policy.domain.SessionId)1 State (uk.gov.ida.hub.policy.domain.State)1 SessionStoreRedisCodec (uk.gov.ida.hub.policy.redis.SessionStoreRedisCodec)1 RedisSessionStore (uk.gov.ida.hub.policy.session.RedisSessionStore)1