public class InMemoryWebSessionStore extends Object implements WebSessionStore
WebSession instances.| Constructor and Description |
|---|
InMemoryWebSessionStore() |
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<WebSession> |
createWebSession()
Create a new WebSession.
|
Clock |
getClock()
Return the configured clock for session lastAccessTime calculations.
|
int |
getMaxSessions()
Return the maximum number of sessions that can be stored.
|
Map<String,WebSession> |
getSessions()
Return the map of sessions with an
unmodifiable wrapper. |
void |
removeExpiredSessions()
Check for expired sessions and remove them.
|
reactor.core.publisher.Mono<Void> |
removeSession(String id)
Remove the WebSession for the specified id.
|
reactor.core.publisher.Mono<WebSession> |
retrieveSession(String id)
Return the WebSession for the given id.
|
void |
setClock(Clock clock)
Configure the
Clock to use to set lastAccessTime on every created
session and to calculate if it is expired. |
void |
setMaxSessions(int maxSessions)
Set the maximum number of sessions that can be stored.
|
reactor.core.publisher.Mono<WebSession> |
updateLastAccessTime(WebSession session)
Update the last accessed timestamp to "now".
|
public void setMaxSessions(int maxSessions)
IllegalStateException.
By default set to 10000.
maxSessions - the maximum number of sessionspublic int getMaxSessions()
public void setClock(Clock clock)
Clock to use to set lastAccessTime on every created
session and to calculate if it is expired.
This may be useful to align to different timezone or to set the clock
back in a test, e.g. Clock.offset(clock, Duration.ofMinutes(-31))
in order to simulate session expiration.
By default this is Clock.system(ZoneId.of("GMT")).
clock - the clock to usepublic Clock getClock()
public Map<String,WebSession> getSessions()
unmodifiable wrapper. This could be used for management purposes, to
list active sessions, invalidate expired ones, etc.public reactor.core.publisher.Mono<WebSession> createWebSession()
WebSessionStoreNote that this does nothing more than create a new instance.
The session can later be started explicitly via WebSession.start()
or implicitly by adding attributes -- and then persisted via
WebSession.save().
createWebSession in interface WebSessionStorepublic reactor.core.publisher.Mono<WebSession> retrieveSession(String id)
WebSessionStoreNote: This method should perform an expiration check, and if it has expired remove the session and return empty. This method should also update the lastAccessTime of retrieved sessions.
retrieveSession in interface WebSessionStoreid - the session to loadMono .public reactor.core.publisher.Mono<Void> removeSession(String id)
WebSessionStoreremoveSession in interface WebSessionStoreid - the id of the session to removepublic reactor.core.publisher.Mono<WebSession> updateLastAccessTime(WebSession session)
WebSessionStoreupdateLastAccessTime in interface WebSessionStoresession - the session to update