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
ConstructorDescriptionReactiveMapSessionRepository
(Map<String, Session> sessions) Creates a new instance backed by the providedMap
. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<MapSession>
Creates a newSession
that 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 theSession
created byReactiveSessionRepository.createSession()
is saved.void
setDefaultMaxInactiveInterval
(Duration defaultMaxInactiveInterval) Set the maximum inactive interval in seconds between requests before newly created sessions will be invalidated.
-
Constructor Details
-
ReactiveMapSessionRepository
- Parameters:
sessions
- theMap
to use. Cannot be null.
-
-
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
-
save
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<MapSession>
- Parameters:
session
- theSession
to save- Returns:
- indicator of operation completion
-
findById
Description copied from interface:ReactiveSessionRepository
- Specified by:
findById
in interfaceReactiveSessionRepository<MapSession>
- 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<MapSession>
- Parameters:
id
- theSession.getId()
to delete- Returns:
- indicator of operation completion
-
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<MapSession>
- Returns:
- a new
Session
that is capable of being persisted by thisReactiveSessionRepository
-