类 InMemorySessionRepository

java.lang.Object
cn.taketoday.session.InMemorySessionRepository
所有已实现的接口:
SessionRepository

public class InMemorySessionRepository extends Object implements SessionRepository
Memory based SessionRepository
从以下版本开始:
2019-09-28 10:31
作者:
Harry Yang
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • 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 an IllegalStateException.

      By default set to 10000.

      参数:
      maxSessions - the maximum number of sessions
      从以下版本开始:
      4.0
    • getMaxSessions

      public int getMaxSessions()
      Return the maximum number of sessions that can be stored.
      从以下版本开始:
      4.0
    • setSessionMaxIdleTime

      public void setSessionMaxIdleTime(@Nullable Duration timeout)
      Set the duration of session idle timeout
      参数:
      timeout - the duration of session idle timeout
      从以下版本开始:
      4.0
    • setNotifyBindingListenerOnUnchangedValue

      public void setNotifyBindingListenerOnUnchangedValue(boolean notifyBindingListenerOnUnchangedValue)
      When an attribute that is already present in the session is added again under the same name and the attribute implements AttributeBindingListener, should AttributeBindingListener.valueUnbound(WebSession, String) be called followed by AttributeBindingListener.valueBound(WebSession, String)

      The default value is false.

      参数:
      notifyBindingListenerOnUnchangedValue - true if the listener will be notified, false if it will not
      从以下版本开始:
      4.0
    • setNotifyAttributeListenerOnUnchangedValue

      public void setNotifyAttributeListenerOnUnchangedValue(boolean notifyAttributeListenerOnUnchangedValue)
      When an attribute that is already present in the session is added again under the same name and a WebSessionAttributeListener is configured for the session should WebSessionAttributeListener.attributeReplaced(WebSession, String, Object, Object) be called?

      The default value is true.

      参数:
      notifyAttributeListenerOnUnchangedValue - true if the listener will be notified, false if it will not
      从以下版本开始:
      4.0
    • setClock

      public void setClock(Clock clock)
      Configure the 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 use
      从以下版本开始:
      4.0
    • getClock

      public Clock getClock()
      Return the configured clock for session lastAccessTime calculations.
      从以下版本开始:
      4.0
    • getSessionCount

      public int getSessionCount()
      指定者:
      getSessionCount 在接口中 SessionRepository
      返回:
      the count of sessions
    • getIdentifiers

      public String[] getIdentifiers()
      指定者:
      getIdentifiers 在接口中 SessionRepository
      返回:
      all session ids
    • getSessions

      public Map<String,WebSession> getSessions()
      Return the map of sessions with an unmodifiable wrapper. This could be used for management purposes, to list active sessions, invalidate expired ones, etc.
    • createSession

      public WebSession createSession()
      从接口复制的说明: SessionRepository
      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 via WebSession.save().

      指定者:
      createSession 在接口中 SessionRepository
      返回:
      the created session instance
    • createSession

      public WebSession createSession(String id)
      从接口复制的说明: SessionRepository
      Create a new WebSession with given session id.

      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().

      指定者:
      createSession 在接口中 SessionRepository
      返回:
      the created session instance
    • retrieveSession

      public WebSession retrieveSession(String id)
      从接口复制的说明: SessionRepository
      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 在接口中 SessionRepository
      参数:
      id - the session to load
      返回:
      the session
    • removeSession

      public WebSession removeSession(String id)
      从接口复制的说明: SessionRepository
      Remove the WebSession for the specified id.
      指定者:
      removeSession 在接口中 SessionRepository
      参数:
      id - the id of the session to remove
      返回:
      an old session
    • updateLastAccessTime

      public void updateLastAccessTime(WebSession session)
      从接口复制的说明: SessionRepository
      Update the last accessed timestamp to "now".
      指定者:
      updateLastAccessTime 在接口中 SessionRepository
      参数:
      session - the session to update
    • contains

      public boolean contains(String id)
      指定者:
      contains 在接口中 SessionRepository
    • removeExpiredSessions

      public void removeExpiredSessions()
      Check for expired sessions and remove them. Typically such checks are kicked off lazily during calls to create or retrieve, no less than 60 seconds apart. This method can be called to force a check at a specific time.
      从以下版本开始:
      4.0