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.
|
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. |
reactor.core.publisher.Mono<WebSession> |
updateLastAccessTime(WebSession webSession)
Update the last accessed timestamp to "now".
|
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 reactor.core.publisher.Mono<WebSession> createWebSession()
WebSessionStore
Note 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 WebSessionStore
public reactor.core.publisher.Mono<WebSession> retrieveSession(String id)
WebSessionStore
Note: 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 WebSessionStore
id
- the session to loadMono
.public reactor.core.publisher.Mono<Void> removeSession(String id)
WebSessionStore
removeSession
in interface WebSessionStore
id
- the id of the session to removepublic reactor.core.publisher.Mono<WebSession> updateLastAccessTime(WebSession webSession)
WebSessionStore
updateLastAccessTime
in interface WebSessionStore
webSession
- the session to update