public interface CachePolicy<K,V>
Modifier and Type | Method and Description |
---|---|
void |
addListener(CachePolicyListener<V> listener)
Add a listener to this cache policy.
|
Enumeration<V> |
elements()
Enumerate through the objects currently in the cache.
|
V |
get(K key)
Obtain the object stored under the key specified.
|
void |
put(K key,
V value)
Place an object in the cache.
|
void |
remove(K key)
Remove the object stored under the key specified.
|
void |
removeAll()
Remove all objects from the cache.
|
void |
removeListener(CachePolicyListener<V> listener)
Remove a listener from this cache policy.
|
void put(K key, V value) throws CacheEvictionException
If the changes to the cache cause the eviction of any objects
stored under other key(s), events corresponding to
the evictions are fired for each object. If an event listener is
unable to handle the eviction, and throws a cache eviction exception,
that exception is propagated to the caller. If such an exception is
thrown, the cache itself should be left as it was before the
put()
operation was invoked: the the object whose
eviction failed is still in the cache, and the new insertion or
modification is reverted.
key
- key for the cached objectvalue
- the cached objectCacheEvictionException
- propagated if, while evicting objects
to make room for new object, an eviction listener encountered
this problem.V get(K key)
key
- key the object was cached undervoid remove(K key)
put( )
).key
- key the object was stored in the cache under.void removeAll()
remove( )
, no eviction notices are fired.Enumeration<V> elements()
void addListener(CachePolicyListener<V> listener) throws IllegalArgumentException
If this cache policy already contains a listener that is equal to the one being added, this call has no effect.
listener
- the (non-null) listener to add to this policyIllegalArgumentException
- if listener is null.void removeListener(CachePolicyListener<V> listener)
listener
- the listener to remove from this policyCopyright © 2003–2013 The Apache Software Foundation. All rights reserved.