Class GrouperCache<K,V>
java.lang.Object
edu.internet2.middleware.grouper.cache.GrouperCache<K,V>
- Type Parameters:
K
-V
-
wrapper around ehcache which makes it genericized
-
Constructor Summary
ConstructorDescriptionGrouperCache
(String cacheName) construct with cache nameGrouperCache
(String cacheName, int defaultMaxElementsInMemory, boolean defaultEternal, int defaultTimeToIdleSeconds, int defaultTimeToLiveSeconds, boolean defaultOverflowToDisk) construct with cache nameGrouperCache
(net.sf.ehcache.Cache theCache) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
remove all in cacheboolean
containsKey
(K key) see if the cache has this element in it.get a value or null if not there or expired this will check for eviction, and evict if evictablenet.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.Cache
keySet()
get a set of the keys in the cachevoid
void
put a value into the cache, accept the default time to live for this cachevoid
register a cache for database clearable.remove an item if it existsvalues()
values
-
Constructor Details
-
GrouperCache
public GrouperCache(net.sf.ehcache.Cache theCache) - Parameters:
theCache
-
-
GrouperCache
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 classnamedefaultMaxElementsInMemory
- if not in config file, this is max elements in memorydefaultEternal
- if not in config file, true to never expire stuffdefaultTimeToIdleSeconds
- if not in config file, time where if not accessed, will expiredefaultTimeToLiveSeconds
- if not in config file, time where even if accessed, will expiredefaultOverflowToDisk
- if not in config file, if it should go to disk in overflow
-
-
Method Details
-
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
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
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
get a set of the keys in the cache- Returns:
- the set of the keys, never returns null
-
remove
remove an item if it exists- Parameters:
key
-- Returns:
- the previous value associated or null (to match Map interface)
-
put
put a value into the cache, accept the default time to live for this cache- Parameters:
key
-value
-
-