Package org.apache.shiro.cache.ehcache
Class EhCache<K,V>
java.lang.Object
org.apache.shiro.cache.ehcache.EhCache<K,V>
- All Implemented Interfaces:
org.apache.shiro.cache.Cache<K,V>
Shiro
Cache implementation that wraps an Ehcache instance.- Since:
- 0.2
-
Constructor Summary
ConstructorsConstructorDescriptionEhCache(net.sf.ehcache.Ehcache cache) Constructs a new EhCache instance with the given cache. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all elements in the cache, but leaves the cache in a useable state.Gets a value of an element which matches the given key.longReturns the size (in bytes) that this EhCache's disk store is consuming or-1if that number is unknown or cannot be calculated.longReturns the size (in bytes) that this EhCache's memory store is using (RAM), or-1if that number is unknown or cannot be calculated.longReturns the size (in bytes) that this EhCache is using in memory (RAM), or-1if that number is unknown or cannot be calculated.keys()Puts an object into the cache.Removes the element which matches the key.intsize()toString()Returns "EhCache [" + cache.getName() + "]"values()
-
Constructor Details
-
EhCache
public EhCache(net.sf.ehcache.Ehcache cache) Constructs a new EhCache instance with the given cache.- Parameters:
cache- - delegate EhCache instance this Shiro cache instance will wrap.
-
-
Method Details
-
get
Gets a value of an element which matches the given key. -
put
Puts an object into the cache. -
remove
Removes the element which matches the key.If no element matches, nothing is removed and no Exception is thrown.
-
clear
public void clear() throws org.apache.shiro.cache.CacheExceptionRemoves all elements in the cache, but leaves the cache in a useable state. -
size
public int size() -
keys
-
values
-
getMemoryUsage
public long getMemoryUsage()Returns the size (in bytes) that this EhCache is using in memory (RAM), or-1if that number is unknown or cannot be calculated.- Returns:
- the size (in bytes) that this EhCache is using in memory (RAM), or
-1if that number is unknown or cannot be calculated.
-
getMemoryStoreSize
public long getMemoryStoreSize()Returns the size (in bytes) that this EhCache's memory store is using (RAM), or-1if that number is unknown or cannot be calculated.- Returns:
- the size (in bytes) that this EhCache's memory store is using (RAM), or
-1if that number is unknown or cannot be calculated.
-
getDiskStoreSize
public long getDiskStoreSize()Returns the size (in bytes) that this EhCache's disk store is consuming or-1if that number is unknown or cannot be calculated.- Returns:
- the size (in bytes) that this EhCache's disk store is consuming or
-1if that number is unknown or cannot be calculated.
-
toString
Returns "EhCache [" + cache.getName() + "]"
-