Search in sources :

Example 1 with RedisSessionStore

use of uk.gov.ida.hub.policy.session.RedisSessionStore 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 2 with RedisSessionStore

use of uk.gov.ida.hub.policy.session.RedisSessionStore in project verify-hub by alphagov.

the class PolicyModule method getRedisSessionStore.

private RedisSessionStore getRedisSessionStore(RedisConfiguration config) {
    RedisClient redisClient = RedisClient.create();
    redisClient.setDefaultTimeout(config.getTimeout());
    StatefulRedisMasterSlaveConnection<SessionId, State> redisConnection = MasterSlave.connect(redisClient, new SessionStoreRedisCodec(getRedisObjectMapper()), singletonList(config.getUri()));
    RedisCommands<SessionId, State> redisCommands = redisConnection.sync();
    return new RedisSessionStore(redisCommands, config.getRecordTTL());
}
Also used : RedisClient(io.lettuce.core.RedisClient) State(uk.gov.ida.hub.policy.domain.State) SessionStoreRedisCodec(uk.gov.ida.hub.policy.redis.SessionStoreRedisCodec) SessionId(uk.gov.ida.hub.policy.domain.SessionId) RedisSessionStore(uk.gov.ida.hub.policy.session.RedisSessionStore)

Aggregations

SessionId (uk.gov.ida.hub.policy.domain.SessionId)2 State (uk.gov.ida.hub.policy.domain.State)2 SessionStoreRedisCodec (uk.gov.ida.hub.policy.redis.SessionStoreRedisCodec)2 RedisSessionStore (uk.gov.ida.hub.policy.session.RedisSessionStore)2 RedisClient (io.lettuce.core.RedisClient)1 RedisURI (io.lettuce.core.RedisURI)1