Class WebSessionKeyCache<T>

  • Type Parameters:
    T - the session key type

    public class WebSessionKeyCache<T>
    extends Object
    A cache mapping user session infos to the web container's session keys.
    Author:
    harald
    • Constructor Detail

      • WebSessionKeyCache

        public WebSessionKeyCache()
        Creates a session key cache.
    • Method Detail

      • startup

        public void startup​(long cleanupInterval)
        Starts the session key cache.

        This will start a thread to cleanup crashed sessions.

        Throws TentackleRuntimeException if the cleanup thread is already running.

        Parameters:
        cleanupInterval - interval in [ms] to run cleanup
      • terminate

        public void terminate()
        Terminates the session cache.

        Throws TentackleRuntimeException if the cleanup thread is not running at all.

      • addSessionInfo

        public void addSessionInfo​(T sessionKey,
                                   org.tentackle.session.SessionInfo sessionInfo)
        Adds a mapping between a session and a session info.
        This is usually done in the login controller. If a session with that key already exists, the user info will be replaced.
        Parameters:
        sessionKey - the (unique) session key
        sessionInfo - the user's session info
      • removeSessionInfo

        public void removeSessionInfo​(T sessionKey)
        Removes a mapping between a session and a session info.
        This is usually done in the logout controller. If there is no such session, the method will do nothing.
        Parameters:
        sessionKey - the (unique) session key
      • getSessionInfo

        public org.tentackle.session.SessionInfo getSessionInfo​(T sessionKey)
        Gets the session info.
        Parameters:
        sessionKey - the session key
        Returns:
        the session info, null if no such session info
      • getSessionKeys

        public Collection<T> getSessionKeys​(org.tentackle.session.SessionInfo sessionInfo)
        Gets the session keys for a user session info.
        Parameters:
        sessionInfo - the user info
        Returns:
        the session keys, never null