Class ReactiveRedisSessionRepository
java.lang.Object
org.springframework.session.data.redis.ReactiveRedisSessionRepository
- All Implemented Interfaces:
ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
- Direct Known Subclasses:
ReactiveRedisOperationsSessionRepository
public class ReactiveRedisSessionRepository
extends Object
implements ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
A
ReactiveSessionRepository
that is implemented using Spring Data's
ReactiveRedisOperations
.- Since:
- 2.2.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The default namespace for each key and channel in Redis used by Spring Session. -
Constructor Summary
ConstructorDescriptionReactiveRedisSessionRepository
(org.springframework.data.redis.core.ReactiveRedisOperations<String, Object> sessionRedisOperations) Create a newReactiveRedisSessionRepository
instance. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
Creates a newSession
that is capable of being persisted by thisReactiveSessionRepository
.reactor.core.publisher.Mono<Void>
deleteById
(String id) reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
Returns theReactiveRedisOperations
used for sessions.reactor.core.publisher.Mono<Void>
save
(org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession session) Ensures theSession
created byReactiveSessionRepository.createSession()
is saved.void
setDefaultMaxInactiveInterval
(int defaultMaxInactiveInterval) Sets the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.void
setRedisKeyNamespace
(String namespace) void
setSaveMode
(SaveMode saveMode) Set the save mode.
-
Field Details
-
DEFAULT_NAMESPACE
The default namespace for each key and channel in Redis used by Spring Session.- See Also:
-
-
Constructor Details
-
ReactiveRedisSessionRepository
public ReactiveRedisSessionRepository(org.springframework.data.redis.core.ReactiveRedisOperations<String, Object> sessionRedisOperations) Create a newReactiveRedisSessionRepository
instance.- Parameters:
sessionRedisOperations
- theReactiveRedisOperations
to use for managing sessions
-
-
Method Details
-
setRedisKeyNamespace
-
setDefaultMaxInactiveInterval
public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) Sets the maximum inactive interval in seconds between requests before newly created sessions will be invalidated. A negative time indicates that the session will never timeout. The default is 1800 (30 minutes).- Parameters:
defaultMaxInactiveInterval
- the number of seconds that theSession
should be kept alive between client requests.
-
setSaveMode
Set the save mode.- Parameters:
saveMode
- the save mode
-
getSessionRedisOperations
public org.springframework.data.redis.core.ReactiveRedisOperations<String,Object> getSessionRedisOperations()Returns theReactiveRedisOperations
used for sessions.- Returns:
- the
ReactiveRedisOperations
used for sessions
-
createSession
public reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession> createSession()Description copied from interface:ReactiveSessionRepository
Creates a newSession
that is capable of being persisted by thisReactiveSessionRepository
.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.- Specified by:
createSession
in interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
- Returns:
- a new
Session
that is capable of being persisted by thisReactiveSessionRepository
-
save
public reactor.core.publisher.Mono<Void> save(org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession session) Description copied from interface:ReactiveSessionRepository
Ensures theSession
created byReactiveSessionRepository.createSession()
is saved.Some implementations may choose to save as the
Session
is updated by returning aSession
that immediately persists any changes. In this case, this method may not actually do anything.- Specified by:
save
in interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
- Parameters:
session
- theSession
to save- Returns:
- indicator of operation completion
-
findById
public reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession> findById(String id) Description copied from interface:ReactiveSessionRepository
- Specified by:
findById
in interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
- Parameters:
id
- theSession.getId()
to lookup- Returns:
- the
Session
by theSession.getId()
or null if noSession
is found.
-
deleteById
Description copied from interface:ReactiveSessionRepository
- Specified by:
deleteById
in interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
- Parameters:
id
- theSession.getId()
to delete- Returns:
- indicator of operation completion
-