Package org.springframework.session
Class ReactiveMapSessionRepository
java.lang.Object
org.springframework.session.ReactiveMapSessionRepository
- All Implemented Interfaces:
ReactiveSessionRepository<MapSession>
public class ReactiveMapSessionRepository
extends Object
implements ReactiveSessionRepository<MapSession>
A
ReactiveSessionRepository backed by a Map and that uses a
MapSession. The injected Map can be backed by a distributed
NoSQL store like Hazelcast, for instance. Note that the supplied map must be a
non-blocking map, and is itself responsible for purging the expired sessions.
The implementation does NOT support firing SessionDeletedEvent or
SessionExpiredEvent.
- Since:
- 2.0
-
Constructor Summary
ConstructorsConstructorDescriptionReactiveMapSessionRepository(Map<String, Session> sessions) Creates a new instance backed by the providedMap. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<MapSession>Creates a newSessionthat is capable of being persisted by thisReactiveSessionRepository.reactor.core.publisher.Mono<Void>deleteById(String id) reactor.core.publisher.Mono<MapSession>reactor.core.publisher.Mono<Void>save(MapSession session) Ensures theSessioncreated byReactiveSessionRepository.createSession()is saved.voidsetDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) If non-null, this value is used to overrideSession.setMaxInactiveInterval(Duration).
-
Constructor Details
-
ReactiveMapSessionRepository
- Parameters:
sessions- theMapto use. Cannot be null.
-
-
Method Details
-
setDefaultMaxInactiveInterval
public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) If non-null, this value is used to overrideSession.setMaxInactiveInterval(Duration).- Parameters:
defaultMaxInactiveInterval- the number of seconds that theSessionshould be kept alive between client requests.
-
save
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<MapSession>- Parameters:
session- theSessionto save- Returns:
- indicator of operation completion
-
findById
Description copied from interface:ReactiveSessionRepository- Specified by:
findByIdin interfaceReactiveSessionRepository<MapSession>- 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<MapSession>- Parameters:
id- theSession.getId()to delete- Returns:
- indicator of operation completion
-
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<MapSession>- Returns:
- a new
Sessionthat is capable of being persisted by thisReactiveSessionRepository
-