Interface SessionCache

All Known Implementing Classes:
AbstractSessionCache, DefaultSessionCache

public interface SessionCache
An interface for managing a set of Session objects pertaining to a context in memory.

Created: 2017. 6. 24.

  • Field Details

  • Method Details

    • isClusterEnabled

      boolean isClusterEnabled()
    • getMaxActiveSessions

      int getMaxActiveSessions()
    • setMaxActiveSessions

      void setMaxActiveSessions(int maxActiveSessions)
      Sets the maximum number of active sessions allowed in this session cache. The number of active sessions exceeds this limit, attempts to create new sessions will be rejected. If set to 0 (the default), there is no limit.
      Parameters:
      maxActiveSessions - the maximum number of active sessions allowed in this session cache
    • getEvictionIdleSecs

      int getEvictionIdleSecs()
      Returns:
      the interval in seconds to evict inactive sessions from cache
    • getEvictionIdleSecsForNew

      int getEvictionIdleSecsForNew()
    • isSaveOnCreate

      boolean isSaveOnCreate()
      Returns:
      if true the newly created session will be saved immediately
    • isSaveOnInactiveEviction

      boolean isSaveOnInactiveEviction()
      Returns:
      true if the session should be saved before being evicted
    • setSaveOnInactiveEviction

      void setSaveOnInactiveEviction(boolean saveOnEvict)
      Whether a session that is about to be evicted should be saved before being evicted.
      Parameters:
      saveOnEvict - if true, save the session before eviction
    • isRemoveUnloadableSessions

      boolean isRemoveUnloadableSessions()
      Returns:
      if true unloadable session will be deleted
    • setRemoveUnloadableSessions

      void setRemoveUnloadableSessions(boolean removeUnloadableSessions)
      If the data for a session exists but is unreadable, the SessionCache can instruct the SessionStore to delete it.
      Parameters:
      removeUnloadableSessions - whether SessionCache will delete session data that can not be loaded from the SessionStore
    • get

      Get an existing Session. If necessary, the cache will load the data for the session from the configured SessionStore.
      Parameters:
      id - the session id
      Returns:
      the Session if one exists, null otherwise
      Throws:
      Exception - if an error occurs
    • add

      ManagedSession add(String id, long time, long inactiveInterval) throws Exception
      Add an entirely new session to the cache.
      Parameters:
      id - the session id
      time - the timestamp of the session creation
      inactiveInterval - the max inactive time in milliseconds
      Throws:
      Exception
    • refresh

      void refresh(ManagedSession session) throws Exception
      Refreshes the data of the session to be used.
      Parameters:
      session - the session object
      Throws:
      Exception - if an error occurs
    • release

      void release(ManagedSession session) throws Exception
      Finish using a Session. This is called by the SessionManager once a request is finished with a Session. SessionCache implementations may want to delay writing out Session contents until the last request exits a Session.
      Parameters:
      session - the session object
      Throws:
      Exception - if an error occurs
    • exists

      boolean exists(String id) throws Exception
      Check to see if a session exists: WILL consult the SessionStore.
      Parameters:
      id - the session id
      Returns:
      true if the session exists; false otherwise
      Throws:
      Exception - if an error occurs
    • contains

      boolean contains(String id) throws Exception
      Check to see if a Session is in the cache. Does NOT consult the SessionStore.
      Parameters:
      id - the session id
      Returns:
      true if a Session object matching the id is present in the cache; false otherwise
      Throws:
      Exception - if an error occurs
    • delete

      ManagedSession delete(String id) throws Exception
      Remove a Session completely: from both this cache and the SessionStore.
      Parameters:
      id - the session id
      Returns:
      the Session that was removed, null otherwise
      Throws:
      Exception - if an error occurs when deleting a session
    • renewSessionId

      ManagedSession renewSessionId(String oldId, String newId) throws Exception
      Change the id of a Session.
      Parameters:
      oldId - the current session id
      newId - the new session id
      Returns:
      the Session after changing its id
      Throws:
      Exception - if any error occurred
    • checkExpiration

      Set<String> checkExpiration(Set<String> candidates)
      Check a list of session ids that belong to potentially expired sessions. The Session in the cache should be checked, but also the SessionStore, as that is the authoritative source of all session information.
      Parameters:
      candidates - the session ids to check
      Returns:
      the set of session ids that have actually expired: this can be a superset of the original candidate list.
    • checkInactiveSession

      boolean checkInactiveSession(ManagedSession session)
      Check a Session to see if it might be appropriate to evict or expire.
      Parameters:
      session - the session object
      Returns:
      true if evicted session, false otherwise
    • cleanOrphans

      void cleanOrphans(long time)
      Remove all unmanaged sessions that expired at or before the given time.
      Parameters:
      time - the time before which the sessions must have expired
    • getActiveSessions

      Set<String> getActiveSessions()
      Returns:
      the identifiers of those sessions that are active on this node, excluding passivated sessions
    • getAllSessions

      Set<String> getAllSessions()
      Returns:
      the identifiers of all sessions, including both active and passive