java.lang.Object
io.jooby.redis.RedisSessionStore
- All Implemented Interfaces:
SessionStore
Redis session store.
- Since:
- 2.8.5
- Author:
- edgar
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jooby.SessionStore
SessionStore.InMemory
-
Field Summary
Fields inherited from interface io.jooby.SessionStore
DEFAULT_TIMEOUT
-
Constructor Summary
ConstructorsConstructorDescriptionRedisSessionStore
(io.lettuce.core.RedisClient redis) Creates a new session store.RedisSessionStore
(org.apache.commons.pool2.impl.GenericObjectPool<io.lettuce.core.api.StatefulRedisConnection<String, String>> pool) Creates a new session store. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteSession
(Context ctx, Session session) findSession
(Context ctx) Redis namespace (key prefix).Session timeout.getToken()
Session token.newSession
(Context ctx) Remove session timeout.void
renewSessionId
(Context ctx, Session session) void
saveSession
(Context ctx, Session session) setNamespace
(String namespace) Set redis namespace or key prefix.setTimeout
(Duration timeout) Set/change session timeout.setToken
(SessionToken token) Set custom session token.void
touchSession
(Context ctx, Session session)
-
Constructor Details
-
RedisSessionStore
public RedisSessionStore(@NonNull org.apache.commons.pool2.impl.GenericObjectPool<io.lettuce.core.api.StatefulRedisConnection<String, String>> pool) Creates a new session store.- Parameters:
pool
- Redis connection pool.
-
RedisSessionStore
public RedisSessionStore(@NonNull io.lettuce.core.RedisClient redis) Creates a new session store.- Parameters:
redis
- Redis connection.
-
-
Method Details
-
getNamespace
Redis namespace (key prefix).- Returns:
- Redis namespace (key prefix). Default is:
sessions
.
-
setNamespace
Set redis namespace or key prefix.- Parameters:
namespace
- Redis namespace or key prefix.- Returns:
- This store.
-
getTimeout
Session timeout.- Returns:
- Session timeout. Default is:
30 minutes
.
-
setTimeout
Set/change session timeout.- Parameters:
timeout
- Timeout must be positive value. Otherwise, timeout is disabled.- Returns:
- This store.
-
noTimeout
Remove session timeout.- Returns:
- This store.
-
getToken
Session token.- Returns:
- Session token. Uses a cookie by default:
SessionToken.SID
.
-
setToken
Set custom session token.- Parameters:
token
- Session token.- Returns:
- This store.
-
newSession
- Specified by:
newSession
in interfaceSessionStore
-
findSession
- Specified by:
findSession
in interfaceSessionStore
-
deleteSession
- Specified by:
deleteSession
in interfaceSessionStore
-
touchSession
- Specified by:
touchSession
in interfaceSessionStore
-
saveSession
- Specified by:
saveSession
in interfaceSessionStore
-
renewSessionId
- Specified by:
renewSessionId
in interfaceSessionStore
-