Class NullSessionCache

  • All Implemented Interfaces:
    SessionCache, Container, Destroyable, Dumpable, LifeCycle

    public class NullSessionCache
    extends AbstractSessionCache
    NullSessionCache Does not actually cache any Session objects. Useful for testing. Also useful if you do not want to share Session objects with the same id between simultaneous requests: note that this means that context forwarding can't share the same id either.
    • Constructor Detail

      • NullSessionCache

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

      • shutdown

        public void shutdown()
      • 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
      • 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
      • 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
      • setEvictionPolicy

        public void setEvictionPolicy​(int evictionTimeout)
        Description copied from class: AbstractSessionCache
        -1 means we never evict inactive sessions. 0 means we evict a session after the last request for it exits >0 is the number of seconds after which we evict inactive sessions from the cache
        Specified by:
        setEvictionPolicy in interface SessionCache
        Overrides:
        setEvictionPolicy in class AbstractSessionCache
        Parameters:
        evictionTimeout - -1 is never evict; 0 is evict-on-exit; and any other positive value is the time in seconds that a session can be idle before it can be evicted.
        See Also:
        SessionCache.setEvictionPolicy(int)
      • 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