public class MRU extends Object implements CachePolicy
Constructor and Description |
---|
MRU(int max)
Construct an MRU with a given maximum number of objects.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addEntry(jdbm.helper.CacheEntry entry)
Add a CacheEntry.
|
void |
addListener(CachePolicyListener listener)
Add a listener to this cache policy
|
Enumeration |
elements()
Enumerate elements' values in the cache
|
Object |
get(Object key)
Obtain an object in the cache
|
protected jdbm.helper.CacheEntry |
purgeEntry()
Purge least recently used object from the cache
|
void |
put(Object key,
Object value)
Place an object in the cache.
|
void |
remove(Object key)
Remove an object from the cache
|
void |
removeAll()
Remove all objects from the cache
|
protected void |
removeEntry(jdbm.helper.CacheEntry entry)
Remove a CacheEntry from linked list
|
void |
removeListener(CachePolicyListener listener)
Remove a listener from this cache policy
|
protected void |
touchEntry(jdbm.helper.CacheEntry entry)
Place entry at the end of linked list -- Most Recently Used
|
public void put(Object key, Object value) throws CacheEvictionException
put
in interface CachePolicy
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.public Object get(Object key)
get
in interface CachePolicy
key
- key the object was cached underpublic void remove(Object key)
remove
in interface CachePolicy
key
- key the object was stored in the cache under.public void removeAll()
removeAll
in interface CachePolicy
public Enumeration elements()
elements
in interface CachePolicy
public void addListener(CachePolicyListener listener)
addListener
in interface CachePolicy
listener
- Listener to add to this policypublic void removeListener(CachePolicyListener listener)
removeListener
in interface CachePolicy
listener
- Listener to remove from this policyprotected void addEntry(jdbm.helper.CacheEntry entry)
protected void removeEntry(jdbm.helper.CacheEntry entry)
protected void touchEntry(jdbm.helper.CacheEntry entry)
protected jdbm.helper.CacheEntry purgeEntry() throws CacheEvictionException
CacheEvictionException
Copyright © 2003-2013 Apache Software Foundation. All Rights Reserved.