Class GrouperCache<K,V>

java.lang.Object
edu.internet2.middleware.grouper.cache.GrouperCache<K,V>
Type Parameters:
K -
V -

public class GrouperCache<K,V> extends Object
wrapper around ehcache which makes it genericized
  • Constructor Summary

    Constructors
    Constructor
    Description
    GrouperCache(String cacheName)
    construct with cache name
    GrouperCache(String cacheName, int defaultMaxElementsInMemory, boolean defaultEternal, int defaultTimeToIdleSeconds, int defaultTimeToLiveSeconds, boolean defaultOverflowToDisk)
    construct with cache name
    GrouperCache(net.sf.ehcache.Cache theCache)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    remove all in cache
    boolean
    see if the cache has this element in it.
    get(K key)
    get a value or null if not there or expired this will check for eviction, and evict if evictable
    net.sf.ehcache.Cache
    generally you wont need this method, but if you need any methods not exposed in this class, use the cache directly...
    net.sf.ehcache.Cache
     
    get a set of the keys in the cache
    void
     
    void
    put(K key, V value)
    put a value into the cache, accept the default time to live for this cache
    void
    register a cache for database clearable.
    remove(K key)
    remove an item if it exists
    values

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GrouperCache

      public GrouperCache(net.sf.ehcache.Cache theCache)
      Parameters:
      theCache -
    • GrouperCache

      public GrouperCache(String cacheName)
      construct with cache name
      Parameters:
      cacheName - should be unique, prefix with fully qualified classname
    • GrouperCache

      public GrouperCache(String cacheName, int defaultMaxElementsInMemory, boolean defaultEternal, int defaultTimeToIdleSeconds, int defaultTimeToLiveSeconds, boolean defaultOverflowToDisk)
      construct with cache name
      Parameters:
      cacheName - should be unique, prefix with fully qualified classname
      defaultMaxElementsInMemory - if not in config file, this is max elements in memory
      defaultEternal - if not in config file, true to never expire stuff
      defaultTimeToIdleSeconds - if not in config file, time where if not accessed, will expire
      defaultTimeToLiveSeconds - if not in config file, time where even if accessed, will expire
      defaultOverflowToDisk - if not in config file, if it should go to disk in overflow
  • Method Details

    • values

      public Collection<V> values()
      values
      Returns:
      the collection of values
    • clear

      public void clear()
      remove all in cache
    • registerDatabaseClearableCache

      public void registerDatabaseClearableCache()
      register a cache for database clearable. Note you cant register one that is already there
      Parameters:
      name -
    • notifyDatabaseOfChanges

      public void notifyDatabaseOfChanges()
    • internal_getCache

      public net.sf.ehcache.Cache internal_getCache()
      Returns:
      cache controller
    • getCache

      public net.sf.ehcache.Cache getCache()
      generally you wont need this method, but if you need any methods not exposed in this class, use the cache directly...
      Returns:
      the cache
    • get

      public V get(K key)
      get a value or null if not there or expired this will check for eviction, and evict if evictable
      Parameters:
      key -
      Returns:
      the value or null if not there or evicted
    • containsKey

      public boolean containsKey(K key)
      see if the cache has this element in it. This updates cache stats
      Parameters:
      key -
      Returns:
      true if contains key (though value still could be null)
    • keySet

      public Set<K> keySet()
      get a set of the keys in the cache
      Returns:
      the set of the keys, never returns null
    • remove

      public V remove(K key)
      remove an item if it exists
      Parameters:
      key -
      Returns:
      the previous value associated or null (to match Map interface)
    • put

      public void put(K key, V value)
      put a value into the cache, accept the default time to live for this cache
      Parameters:
      key -
      value -