Package org.apache.shiro.cache
Class MapCache<K,V>
- java.lang.Object
-
- org.apache.shiro.cache.MapCache<K,V>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear all entries from the cache.V
get(K key)
Returns the Cached value stored under the specifiedkey
ornull
if there is no Cache entry for thatkey
.Set<K>
keys()
Returns a view of all the keys for entries contained in this cache.V
put(K key, V value)
Adds a Cache entry.V
remove(K key)
Remove the cache entry corresponding to the specified key.int
size()
Returns the number of entries in the cache.String
toString()
Collection<V>
values()
Returns a view of all of the values contained in this cache.
-
-
-
Method Detail
-
get
public V get(K key) throws CacheException
Description copied from interface:Cache
Returns the Cached value stored under the specifiedkey
ornull
if there is no Cache entry for thatkey
.- Specified by:
get
in interfaceCache<K,V>
- Parameters:
key
- the key that the value was previous added with- Returns:
- the cached object or
null
if there is no entry for the specifiedkey
- Throws:
CacheException
- if there is a problem accessing the underlying cache system
-
put
public V put(K key, V value) throws CacheException
Description copied from interface:Cache
Adds a Cache entry.- Specified by:
put
in interfaceCache<K,V>
- Parameters:
key
- the key used to identify the object being stored.value
- the value to be stored in the cache.- Returns:
- the previous value associated with the given
key
ornull
if there was previous value - Throws:
CacheException
- if there is a problem accessing the underlying cache system
-
remove
public V remove(K key) throws CacheException
Description copied from interface:Cache
Remove the cache entry corresponding to the specified key.- Specified by:
remove
in interfaceCache<K,V>
- Parameters:
key
- the key of the entry to be removed.- Returns:
- the previous value associated with the given
key
ornull
if there was previous value - Throws:
CacheException
- if there is a problem accessing the underlying cache system
-
clear
public void clear() throws CacheException
Description copied from interface:Cache
Clear all entries from the cache.- Specified by:
clear
in interfaceCache<K,V>
- Throws:
CacheException
- if there is a problem accessing the underlying cache system
-
size
public int size()
Description copied from interface:Cache
Returns the number of entries in the cache.
-
keys
public Set<K> keys()
Description copied from interface:Cache
Returns a view of all the keys for entries contained in this cache.
-
values
public Collection<V> values()
Description copied from interface:Cache
Returns a view of all of the values contained in this cache.
-
-