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>
public class EhCache<K,V> extends Object implements org.apache.shiro.cache.Cache<K,V>
ShiroCacheimplementation that wraps anEhcacheinstance.- Since:
- 0.2
-
-
Constructor Summary
Constructors Constructor Description EhCache(net.sf.ehcache.Ehcache cache)Constructs a new EhCache instance with the given cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all elements in the cache, but leaves the cache in a useable state.Vget(K key)Gets a value of an element which matches the given key.longgetDiskStoreSize()Returns the size (in bytes) that this EhCache's disk store is consuming or-1if that number is unknown or cannot be calculated.longgetMemoryStoreSize()Returns the size (in bytes) that this EhCache's memory store is using (RAM), or-1if that number is unknown or cannot be calculated.longgetMemoryUsage()Returns the size (in bytes) that this EhCache is using in memory (RAM), or-1if that number is unknown or cannot be calculated.Set<K>keys()Vput(K key, V value)Puts an object into the cache.Vremove(K key)Removes the element which matches the key.intsize()StringtoString()Returns "EhCache [" + cache.getName() + "]"Collection<V>values()
-
-
-
Method Detail
-
get
public V get(K key) throws org.apache.shiro.cache.CacheException
Gets a value of an element which matches the given key.
-
put
public V put(K key, V value) throws org.apache.shiro.cache.CacheException
Puts an object into the cache.
-
remove
public V remove(K key) throws org.apache.shiro.cache.CacheException
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.
-
values
public Collection<V> 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.
-
-