public class ReactiveMapSessionRepository extends java.lang.Object implements ReactiveSessionRepository<MapSession>
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.
| Constructor and Description |
|---|
ReactiveMapSessionRepository(java.util.Map<java.lang.String,Session> sessions)
Creates a new instance backed by the provided
Map. |
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<MapSession> |
createSession()
Creates a new
Session that is capable of being persisted by this
ReactiveSessionRepository. |
reactor.core.publisher.Mono<java.lang.Void> |
deleteById(java.lang.String id)
|
reactor.core.publisher.Mono<MapSession> |
findById(java.lang.String id)
|
reactor.core.publisher.Mono<java.lang.Void> |
save(MapSession session)
Ensures the
Session created by
ReactiveSessionRepository.createSession() is saved. |
void |
setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
If non-null, this value is used to override
Session.setMaxInactiveInterval(Duration). |
public ReactiveMapSessionRepository(java.util.Map<java.lang.String,Session> sessions)
Map. This allows injecting a
distributed Map.sessions - the Map to use. Cannot be null.public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
Session.setMaxInactiveInterval(Duration).defaultMaxInactiveInterval - the number of seconds that the Session
should be kept alive between client requests.public reactor.core.publisher.Mono<java.lang.Void> save(MapSession session)
ReactiveSessionRepositorySession created by
ReactiveSessionRepository.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 ReactiveSessionRepository<MapSession>session - the Session to savepublic reactor.core.publisher.Mono<MapSession> findById(java.lang.String id)
ReactiveSessionRepositoryfindById in interface ReactiveSessionRepository<MapSession>id - the Session.getId() to lookupSession by the Session.getId() or null if no
Session is found.public reactor.core.publisher.Mono<java.lang.Void> deleteById(java.lang.String id)
ReactiveSessionRepositorydeleteById in interface ReactiveSessionRepository<MapSession>id - the Session.getId() to deletepublic reactor.core.publisher.Mono<MapSession> createSession()
ReactiveSessionRepositorySession that is capable of being persisted by this
ReactiveSessionRepository.
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 ReactiveSessionRepository<MapSession>Session that is capable of being persisted by this
ReactiveSessionRepository