public class MapReactorSessionRepository extends java.lang.Object implements ReactorSessionRepository<MapSession>
SessionRepository
backed by a Map
and that uses a
MapSession
. By default a ConcurrentHashMap
is
used, but a custom Map
can be injected to use distributed maps
provided by NoSQL stores like Redis and Hazelcast.
The implementation does NOT support firing SessionDeletedEvent
or
SessionExpiredEvent
.
Constructor and Description |
---|
MapReactorSessionRepository()
Creates an instance backed by a
ConcurrentHashMap . |
MapReactorSessionRepository(java.lang.Iterable<Session> sessions)
Creates a new instance backed by the provided
Map . |
MapReactorSessionRepository(java.util.Map<java.lang.String,Session> sessions)
Creates a new instance backed by the provided
Map . |
MapReactorSessionRepository(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
ReactorSessionRepository . |
reactor.core.publisher.Mono<java.lang.Void> |
delete(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
ReactorSessionRepository.createSession() is saved. |
void |
setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval)
If non-null, this value is used to override
Session.setMaxInactiveInterval(Duration) . |
public MapReactorSessionRepository()
ConcurrentHashMap
.public MapReactorSessionRepository(java.util.Map<java.lang.String,Session> sessions)
Map
. This allows
injecting a distributed Map
.sessions
- the Map
to use. Cannot be null.public MapReactorSessionRepository(Session... sessions)
Map
. This allows
injecting a distributed Map
.sessions
- the Map
to use. Cannot be null.public MapReactorSessionRepository(java.lang.Iterable<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)
ReactorSessionRepository
Session
created by
ReactorSessionRepository.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 ReactorSessionRepository<MapSession>
session
- the Session
to savepublic reactor.core.publisher.Mono<MapSession> findById(java.lang.String id)
ReactorSessionRepository
findById
in interface ReactorSessionRepository<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> delete(java.lang.String id)
ReactorSessionRepository
delete
in interface ReactorSessionRepository<MapSession>
id
- the Session.getId()
to deletepublic reactor.core.publisher.Mono<MapSession> createSession()
ReactorSessionRepository
Session
that is capable of being persisted by this
ReactorSessionRepository
.
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 ReactorSessionRepository<MapSession>
Session
that is capable of being persisted by this
ReactorSessionRepository