public class RedisSessionRepository extends java.lang.Object implements SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>
SessionRepository implementation that uses Spring Data's
RedisOperations to store sessions is Redis.
This implementation does not support publishing of session events.
| Constructor and Description |
|---|
RedisSessionRepository(org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.Object> sessionRedisOperations)
Create a new
RedisSessionRepository instance. |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.session.data.redis.RedisSessionRepository.RedisSession |
createSession()
Creates a new
Session that is capable of being persisted by this
SessionRepository. |
void |
deleteById(java.lang.String sessionId)
|
org.springframework.session.data.redis.RedisSessionRepository.RedisSession |
findById(java.lang.String sessionId)
|
org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.Object> |
getSessionRedisOperations()
Returns the
RedisOperations used for sessions. |
void |
save(org.springframework.session.data.redis.RedisSessionRepository.RedisSession session)
Ensures the
Session created by
SessionRepository.createSession() is saved. |
void |
setDefaultMaxInactiveInterval(java.time.Duration defaultMaxInactiveInterval)
Set the default maxInactiveInterval.
|
void |
setFlushMode(FlushMode flushMode)
Set the flush mode.
|
void |
setKeyNamespace(java.lang.String keyNamespace)
Deprecated.
since 2.4.0 in favor of
setRedisKeyNamespace(String) |
void |
setRedisKeyNamespace(java.lang.String namespace)
Set the Redis key namespace.
|
void |
setSaveMode(SaveMode saveMode)
Set the save mode.
|
public RedisSessionRepository(org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.Object> sessionRedisOperations)
RedisSessionRepository instance.sessionRedisOperations - the RedisOperations to use for managing
sessionspublic void setDefaultMaxInactiveInterval(java.time.Duration defaultMaxInactiveInterval)
defaultMaxInactiveInterval - the default maxInactiveInterval@Deprecated public void setKeyNamespace(java.lang.String keyNamespace)
setRedisKeyNamespace(String)keyNamespace - the key namespacepublic void setRedisKeyNamespace(java.lang.String namespace)
namespace - the Redis key namespacepublic void setFlushMode(FlushMode flushMode)
flushMode - the flush modepublic void setSaveMode(SaveMode saveMode)
saveMode - the save modepublic org.springframework.session.data.redis.RedisSessionRepository.RedisSession createSession()
SessionRepositorySession that is capable of being persisted by this
SessionRepository.
This allows optimizations and customizations in how the Session is
persisted. For example, the implementation returned might keep track of the changes
ensuring that only the delta needs to be persisted on a save.
createSession in interface SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>Session that is capable of being persisted by this
SessionRepositorypublic void save(org.springframework.session.data.redis.RedisSessionRepository.RedisSession session)
SessionRepositorySession created by
SessionRepository.createSession() is saved.
Some implementations may choose to save as the Session is updated by
returning a Session that immediately persists any changes. In this case,
this method may not actually do anything.
save in interface SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>session - the Session to savepublic org.springframework.session.data.redis.RedisSessionRepository.RedisSession findById(java.lang.String sessionId)
SessionRepositoryfindById in interface SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>sessionId - the Session.getId() to lookupSession by the Session.getId() or null if no
Session is found.public void deleteById(java.lang.String sessionId)
SessionRepositorydeleteById in interface SessionRepository<org.springframework.session.data.redis.RedisSessionRepository.RedisSession>sessionId - the Session.getId() to deletepublic org.springframework.data.redis.core.RedisOperations<java.lang.String,java.lang.Object> getSessionRedisOperations()
RedisOperations used for sessions.RedisOperations used for sessions