Interface SessionCache

  • All Known Implementing Classes:
    BasicSessionCache

    public interface SessionCache
    SessionCache is a general receiving area for data represented as key-value pairs. Entries in a SessionCache may persist for the length of a Virtual Machine's run time, but may be evicted at any time.

    Eviction of SessionCache entries is accomplished by controlling the maximum number of entries in the cache. This maximum value is set by calling setCapacity(int). A SessionCache may be implemented with any eviction policy (including a policy of no eviction). Most implementations evict the eldest entry added to the cache.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()
      Removes all entries from the cache.
      boolean contains​(java.lang.Object key)
      Returns true if the cache contains a specified key, and false if it does not.
      java.lang.Object get​(java.lang.Object key)
      Returns a reference to an entry's value in the cache corresponding to a specified key, or null if no entry with that key exists.
      int getCapacity()
      Returns the maximum number of entries in the cache.
      int getEntryCount()
      Returns the number of entries currently in the cache.
      java.util.Set<java.lang.Object> getKeySet()
      Returns a Set view of the keys contained in the cache.
      void put​(java.lang.Object key, java.lang.Object value)
      Adds an entry in the cache with a specified key and value.
      java.lang.Object remove​(java.lang.Object key)
      Removes the entry with the specified key from the cache, and returns that entry's value.
      void setCapacity​(int capacity)
      Sets the maximum number of entries in the cache.
    • Method Detail

      • getCapacity

        int getCapacity()
        Returns the maximum number of entries in the cache.
        Returns:
        maximum number of entries in the cache.
      • setCapacity

        void setCapacity​(int capacity)
        Sets the maximum number of entries in the cache.
        Parameters:
        capacity - maximum number of enties in the cache.
      • getEntryCount

        int getEntryCount()
        Returns the number of entries currently in the cache.
        Returns:
        number of cached entries.
      • getKeySet

        java.util.Set<java.lang.Object> getKeySet()
        Returns a Set view of the keys contained in the cache.
        Returns:
        a Set view of the keys contained in the cache.
      • contains

        boolean contains​(java.lang.Object key)
        Returns true if the cache contains a specified key, and false if it does not.
        Parameters:
        key - the entry key in question.
        Returns:
        true if the cache contains the key; false otherwise.
      • get

        java.lang.Object get​(java.lang.Object key)
        Returns a reference to an entry's value in the cache corresponding to a specified key, or null if no entry with that key exists.
        Parameters:
        key - the entry key to look for.
        Returns:
        a reference to the found entry's value.
      • put

        void put​(java.lang.Object key,
                 java.lang.Object value)
        Adds an entry in the cache with a specified key and value.
        Parameters:
        key - the entry's key.
        value - the entry's value.
      • remove

        java.lang.Object remove​(java.lang.Object key)
        Removes the entry with the specified key from the cache, and returns that entry's value. If no entry exists for the specified key, this does nothing and returns null.
        Parameters:
        key - the entry key to look for.
        Returns:
        a reference to the removed entry's value, or null of no entry matches the specified key.
      • clear

        void clear()
        Removes all entries from the cache.