Class DefaultSessionCache

    • Field Detail

      • _sessions

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​Session> _sessions
        The cache of sessions in a hashmap
    • Constructor Detail

      • DefaultSessionCache

        public DefaultSessionCache​(SessionHandler manager)
        Parameters:
        manager - The SessionHandler related to this SessionCache
    • Method Detail

      • getSessionsCurrent

        @ManagedAttribute(value="current sessions in cache",
                          readonly=true)
        public long getSessionsCurrent()
        Returns:
        the number of sessions in the cache
      • getSessionsMax

        @ManagedAttribute(value="max sessions in cache",
                          readonly=true)
        public long getSessionsMax()
        Returns:
        the max number of sessions in the cache
      • getSessionsTotal

        @ManagedAttribute(value="total sessions in cache",
                          readonly=true)
        public long getSessionsTotal()
        Returns:
        a running total of sessions in the cache
      • doGet

        public Session doGet​(java.lang.String id)
        Description copied from class: AbstractSessionCache
        Get the session matching the key from the cache. Does not load the session.
        Specified by:
        doGet in class AbstractSessionCache
        Parameters:
        id - session id
        Returns:
        the Session object matching the id
      • doPutIfAbsent

        public Session doPutIfAbsent​(java.lang.String id,
                                     Session session)
        Description copied from class: AbstractSessionCache
        Put the session into the map if it wasn't already there
        Specified by:
        doPutIfAbsent in class AbstractSessionCache
        Parameters:
        id - the identity of the session
        session - the session object
        Returns:
        null if the session wasn't already in the map, or the existing entry otherwise
      • doComputeIfAbsent

        protected Session doComputeIfAbsent​(java.lang.String id,
                                            java.util.function.Function<java.lang.String,​Session> mappingFunction)
        Description copied from class: AbstractSessionCache
        Compute the mappingFunction to create a Session object iff the session with the given id isn't already in the map, otherwise return the existing Session. This method is expected to have precisely the same behaviour as ConcurrentHashMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
        Specified by:
        doComputeIfAbsent in class AbstractSessionCache
        Parameters:
        id - the session id
        mappingFunction - the function to load the data for the session
        Returns:
        an existing Session from the cache
      • doDelete

        public Session doDelete​(java.lang.String id)
        Description copied from class: AbstractSessionCache
        Remove the session with this identity from the store
        Specified by:
        doDelete in class AbstractSessionCache
        Parameters:
        id - the id
        Returns:
        Session that was removed or null
      • shutdown

        public void shutdown()
      • doReplace

        public boolean doReplace​(java.lang.String id,
                                 Session oldValue,
                                 Session newValue)
        Description copied from class: AbstractSessionCache
        Replace the mapping from id to oldValue with newValue
        Specified by:
        doReplace in class AbstractSessionCache
        Parameters:
        id - the id
        oldValue - the old value
        newValue - the new value
        Returns:
        true if replacement was done