| jdbm.helper.CachePolicy
All known Subclasses: jdbm.helper.SoftCache, jdbm.helper.MRU,
CachePolicy | public interface CachePolicy (Code) | | CachePolicity is an abstraction for different cache policies.
(ie. MRU, time-based, soft-refs, ...)
author: Alex Boisvert author: Dilum Ranatunga version: $Id: CachePolicy.java,v 1.5 2003/11/01 13:25:02 dranatunga Exp $ |
addListener | public void addListener(CachePolicyListener listener) throws IllegalArgumentException(Code) | | Add a listener to this cache policy.
If this cache policy already contains a listener that is equal to
the one being added, this call has no effect.
Parameters: listener - the (non-null) listener to add to this policy throws: IllegalArgumentException - if listener is null. |
elements | public Enumeration elements()(Code) | | Enumerate through the objects currently in the cache.
|
get | public Object get(Object key)(Code) | | Obtain the object stored under the key specified.
Parameters: key - key the object was cached under the object if it is still in the cache, null otherwise. |
put | public void put(Object key, Object value) throws CacheEvictionException(Code) | | Place an object in the cache. If the cache does not currently contain
an object for the key specified, this mapping is added. If an object
currently exists under the specified key, the current object is
replaced with the new object.
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.
Parameters: key - key for the cached object Parameters: value - the cached object throws: CacheEvictionException - propagated if, while evicting objectsto make room for new object, an eviction listener encounteredthis problem. |
remove | public void remove(Object key)(Code) | | Remove the object stored under the key specified. Note that since
eviction notices are only fired when objects under different
keys are evicted, no event is fired for any object stored
under this key (see
CachePolicy.put(Object,Object) put( ) ).
Parameters: key - key the object was stored in the cache under. |
removeListener | public void removeListener(CachePolicyListener listener)(Code) | | Remove a listener from this cache policy. The listener is found
using object equality, not identity.
Parameters: listener - the listener to remove from this policy |
|
|