类 InMemoryWebSessionStore
- java.lang.Object
- org.springframework.web.server.session.InMemoryWebSessionStore
- 所有已实现的接口:
WebSessionStore
public class InMemoryWebSessionStore extends Object implements WebSessionStore
Simple Map-based storage forWebSession
instances.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Rob Winch
构造器概要
构造器 构造器 说明 InMemoryWebSessionStore()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 anunmodifiable
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 theClock
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".
构造器详细资料
InMemoryWebSessionStore
public InMemoryWebSessionStore()
方法详细资料
setMaxSessions
public void setMaxSessions(int maxSessions)
Set the maximum number of sessions that can be stored. Once the limit is reached, any attempt to store an additional session will result in anIllegalStateException
.By default set to 10000.
- 参数:
maxSessions
- the maximum number of sessions- 从以下版本开始:
- 5.0.8
getMaxSessions
public int getMaxSessions()
Return the maximum number of sessions that can be stored.- 从以下版本开始:
- 5.0.8
setClock
public void setClock(Clock clock)
Configure theClock
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 use
getSessions
public Map<String,WebSession> getSessions()
Return the map of sessions with anunmodifiable
wrapper. This could be used for management purposes, to list active sessions, invalidate expired ones, etc.- 从以下版本开始:
- 5.0.8
createWebSession
public reactor.core.publisher.Mono<WebSession> createWebSession()
从接口复制的说明:WebSessionStore
Create a new WebSession.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 viaWebSession.save()
.- 指定者:
createWebSession
在接口中WebSessionStore
- 返回:
- the created session instance
retrieveSession
public reactor.core.publisher.Mono<WebSession> retrieveSession(String id)
从接口复制的说明:WebSessionStore
Return the WebSession for the given id.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
在接口中WebSessionStore
- 参数:
id
- the session to load- 返回:
- the session, or an empty
Mono
.
removeSession
public reactor.core.publisher.Mono<Void> removeSession(String id)
从接口复制的说明:WebSessionStore
Remove the WebSession for the specified id.- 指定者:
removeSession
在接口中WebSessionStore
- 参数:
id
- the id of the session to remove- 返回:
- a completion notification (success or error)
updateLastAccessTime
public reactor.core.publisher.Mono<WebSession> updateLastAccessTime(WebSession session)
从接口复制的说明:WebSessionStore
Update the last accessed timestamp to "now".- 指定者:
updateLastAccessTime
在接口中WebSessionStore
- 参数:
session
- the session to update- 返回:
- the session with the updated last access time
removeExpiredSessions
public void removeExpiredSessions()
Check for expired sessions and remove them. Typically such checks are kicked off lazily during calls tocreate
orretrieve
, no less than 60 seconds apart. This method can be called to force a check at a specific time.- 从以下版本开始:
- 5.0.8