Class RedisSessionRepository
java.lang.Object
org.springframework.session.data.redis.RedisSessionRepository
- All Implemented Interfaces:
org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
public class RedisSessionRepository
extends Object
implements org.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
A
SessionRepository implementation that uses Spring Data's
RedisOperations to store sessions is Redis.
This implementation does not support publishing of session events.
- Since:
- 2.2.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default namespace for each key and channel in Redis used by Spring Session. -
Constructor Summary
ConstructorsConstructorDescriptionRedisSessionRepository(org.springframework.data.redis.core.RedisOperations<String, Object> sessionRedisOperations) Create a newRedisSessionRepositoryinstance. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.session.data.redis.RedisSessionRepository.RedisSessionvoiddeleteById(String sessionId) org.springframework.session.data.redis.RedisSessionRepository.RedisSessionReturns theRedisOperationsused for sessions.voidsave(org.springframework.session.data.redis.RedisSessionRepository.RedisSession session) voidsetDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.voidsetFlushMode(org.springframework.session.FlushMode flushMode) Set the flush mode.voidsetRedisKeyNamespace(String namespace) Set the Redis key namespace.voidsetRedisSessionMapper(BiFunction<String, Map<String, Object>, org.springframework.session.MapSession> redisSessionMapper) voidsetSaveMode(org.springframework.session.SaveMode saveMode) Set the save mode.voidsetSessionIdGenerator(org.springframework.session.SessionIdGenerator sessionIdGenerator) Set theSessionIdGeneratorto use to generate session ids.
-
Field Details
-
DEFAULT_KEY_NAMESPACE
The default namespace for each key and channel in Redis used by Spring Session.- See Also:
-
-
Constructor Details
-
RedisSessionRepository
public RedisSessionRepository(org.springframework.data.redis.core.RedisOperations<String, Object> sessionRedisOperations) Create a newRedisSessionRepositoryinstance.- Parameters:
sessionRedisOperations- theRedisOperationsto use for managing sessions
-
-
Method Details
-
setDefaultMaxInactiveInterval
Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never time out. The default is 30 minutes.- Parameters:
defaultMaxInactiveInterval- the default maxInactiveInterval
-
setRedisKeyNamespace
Set the Redis key namespace.- Parameters:
namespace- the Redis key namespace
-
setFlushMode
public void setFlushMode(org.springframework.session.FlushMode flushMode) Set the flush mode.- Parameters:
flushMode- the flush mode
-
setSaveMode
public void setSaveMode(org.springframework.session.SaveMode saveMode) Set the save mode.- Parameters:
saveMode- the save mode
-
createSession
public org.springframework.session.data.redis.RedisSessionRepository.RedisSession createSession()- Specified by:
createSessionin interfaceorg.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
-
save
public void save(org.springframework.session.data.redis.RedisSessionRepository.RedisSession session) - Specified by:
savein interfaceorg.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
-
findById
public org.springframework.session.data.redis.RedisSessionRepository.RedisSession findById(String sessionId) - Specified by:
findByIdin interfaceorg.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
-
deleteById
- Specified by:
deleteByIdin interfaceorg.springframework.session.SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
-
getSessionRedisOperations
public org.springframework.data.redis.core.RedisOperations<String,Object> getSessionRedisOperations()Returns theRedisOperationsused for sessions.- Returns:
- the
RedisOperationsused for sessions
-
setSessionIdGenerator
public void setSessionIdGenerator(org.springframework.session.SessionIdGenerator sessionIdGenerator) Set theSessionIdGeneratorto use to generate session ids.- Parameters:
sessionIdGenerator- theSessionIdGeneratorto use- Since:
- 3.2
-
setRedisSessionMapper
public void setRedisSessionMapper(BiFunction<String, Map<String, Object>, org.springframework.session.MapSession> redisSessionMapper) - Parameters:
redisSessionMapper- the mapper to use, cannot be null- Since:
- 3.2
-