|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CachePolicy<K,V>
CachePolicity is an abstraction for different cache policies. (ie. MRU, time-based, soft-refs, ...)
Method Summary | |
---|---|
void |
addListener(CachePolicyListener<V> listener)
Add a listener to this cache policy. |
java.util.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. |
Method Detail |
---|
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 object
CacheEvictionException
- 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 under
void remove(K key)
put( )
).
key
- key the object was stored in the cache under.void removeAll()
remove( )
, no eviction notices are fired.
java.util.Enumeration<V> elements()
void addListener(CachePolicyListener<V> listener) throws java.lang.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 policy
java.lang.IllegalArgumentException
- if listener is null.void removeListener(CachePolicyListener<V> listener)
listener
- the listener to remove from this policy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |