edu.internet2.middleware.grouper.cache
Class GrouperCache<K,V>

java.lang.Object
  extended by 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
GrouperCache(net.sf.ehcache.Cache theCache)
           
GrouperCache(String cacheName)
          construct with cache name
GrouperCache(String cacheName, int defaultMaxElementsInMemory, boolean defaultEternal, int defaultTimeToIdleSeconds, int defaultTimeToLiveSeconds, boolean defaultOverflowToDisk)
          construct with cache name
 
Method Summary
 void clear()
          remove all in cache
 boolean containsKey(K key)
          see if the cache has this element in it.
 V 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 getCache()
          generally you wont need this method, but if you need any methods not exposed in this class, use the cache directly...
 net.sf.ehcache.Statistics getStats()
           
 net.sf.ehcache.Cache internal_getCache()
           
 Set<K> keySet()
          get a set of the keys in the cache
 void put(K key, V value)
          put a value into the cache, accept the default time to live for this cache
 V remove(K key)
          remove an item if it exists
 Collection<V> values()
          values
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

values

public Collection<V> values()
values

Returns:
the collection of values

clear

public void clear()
remove all in cache


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 -

getStats

public net.sf.ehcache.Statistics getStats()
Returns:
ehcache statistics for cache.
Since:
1.2.1