public class MRU<K,V> extends Object implements CachePolicy<K,V>
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<V> |
elements()
Enumerate elements' values in the cache
|
V |
get(K key)
Obtain an object in the cache
|
protected jdbm.helper.CacheEntry |
purgeEntry()
Purge least recently used object from the cache
|
void |
put(K key,
V value)
Place an object in the cache.
|
void |
remove(K 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, and relink the
remaining element sin the 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(K key, V value) throws CacheEvictionException
put
in interface CachePolicy<K,V>
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 V get(K key)
get
in interface CachePolicy<K,V>
key
- key the object was cached underpublic void remove(K key)
remove
in interface CachePolicy<K,V>
key
- key the object was stored in the cache under.public void removeAll()
removeAll
in interface CachePolicy<K,V>
public Enumeration<V> elements()
elements
in interface CachePolicy<K,V>
public void addListener(CachePolicyListener listener)
addListener
in interface CachePolicy<K,V>
listener
- Listener to add to this policypublic void removeListener(CachePolicyListener listener)
removeListener
in interface CachePolicy<K,V>
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 © 2018. All rights reserved.