Class ReactiveRedisSessionRepository
java.lang.Object
org.springframework.session.data.redis.ReactiveRedisSessionRepository
- All Implemented Interfaces:
ReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>
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
FieldsModifier and TypeFieldDescriptionstatic final StringThe default namespace for each key and channel in Redis used by Spring Session. -
Constructor Summary
ConstructorsConstructorDescriptionReactiveRedisSessionRepository(org.springframework.data.redis.core.ReactiveRedisOperations<String, Object> sessionRedisOperations) Create a newReactiveRedisSessionRepositoryinstance. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>Creates a newSessionthat 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 theReactiveRedisOperationsused for sessions.reactor.core.publisher.Mono<Void>save(org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession session) Ensures theSessioncreated byReactiveSessionRepository.createSession()is saved.voidsetDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) Deprecated.voidsetDefaultMaxInactiveInterval(Duration defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.voidsetRedisKeyNamespace(String namespace) voidsetSaveMode(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 newReactiveRedisSessionRepositoryinstance.- Parameters:
sessionRedisOperations- theReactiveRedisOperationsto use for managing sessions
-
-
Method Details
-
setRedisKeyNamespace
-
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
-
setDefaultMaxInactiveInterval
@Deprecated(since="3.0.0") public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) Deprecated.since 3.0.0, in favor ofsetDefaultMaxInactiveInterval(Duration)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 1800 (30 minutes).- Parameters:
defaultMaxInactiveInterval- the default maxInactiveInterval in seconds
-
setSaveMode
Set the save mode.- Parameters:
saveMode- the save mode
-
getSessionRedisOperations
public org.springframework.data.redis.core.ReactiveRedisOperations<String,Object> getSessionRedisOperations()Returns theReactiveRedisOperationsused for sessions.- Returns:
- the
ReactiveRedisOperationsused for sessions
-
createSession
public reactor.core.publisher.Mono<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession> createSession()Description copied from interface:ReactiveSessionRepositoryCreates a newSessionthat is capable of being persisted by thisReactiveSessionRepository.This allows optimizations and customizations in how the
Sessionis 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:
createSessionin interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>- Returns:
- a new
Sessionthat 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:ReactiveSessionRepositoryEnsures theSessioncreated byReactiveSessionRepository.createSession()is saved.Some implementations may choose to save as the
Sessionis updated by returning aSessionthat immediately persists any changes. In this case, this method may not actually do anything.- Specified by:
savein interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>- Parameters:
session- theSessionto 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:
findByIdin interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>- Parameters:
id- theSession.getId()to lookup- Returns:
- the
Sessionby theSession.getId()or null if noSessionis found.
-
deleteById
Description copied from interface:ReactiveSessionRepository- Specified by:
deleteByIdin interfaceReactiveSessionRepository<org.springframework.session.data.redis.ReactiveRedisSessionRepository.RedisSession>- Parameters:
id- theSession.getId()to delete- Returns:
- indicator of operation completion
-
setDefaultMaxInactiveInterval(Duration)