|
||||||||||
| PREV CLASS (src) NEXT CLASS (src) | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.util.LRUCachePolicy
Implementation of a Least Recently Used cache policy.
| Nested Class Summary | |
class |
LRUCachePolicy.LRUCacheEntry (src)
Double linked cell used as entry in the cache list. |
class |
LRUCachePolicy.LRUList (src)
Double queued list used to store cache entries. |
| Field Summary | |
protected LRUCachePolicy.LRUList (src) |
m_list
The linked list used to implement the LRU algorithm |
protected java.util.HashMap |
m_map
The map holding the cached objects |
protected int |
m_maxCapacity
The maximum capacity of this cache |
protected int |
m_minCapacity
The minimum capacity of this cache |
| Constructor Summary | |
LRUCachePolicy()
Creates a LRU cache policy object with zero cache capacity. |
|
LRUCachePolicy(int min,
int max)
Creates a LRU cache policy object with the specified minimum and maximum capacity. |
|
| Method Summary | |
protected void |
ageOut(LRUCachePolicy.LRUCacheEntry (src) entry)
Callback method called when the cache algorithm ages out of the cache the given entry. |
protected void |
cacheMiss()
Callback method called when a cache miss happens. |
void |
create()
Initializes the cache, creating all required objects and initializing their values. |
protected LRUCachePolicy.LRUCacheEntry (src) |
createCacheEntry(java.lang.Object key,
java.lang.Object value)
Factory method for cache entries |
protected LRUCachePolicy.LRUList (src) |
createList()
Factory method for the linked list used by this cache implementation. |
void |
destroy()
Destroys the cache that is now unusable. |
void |
flush()
Flushes the cached objects from the cache. |
java.lang.Object |
get(java.lang.Object key)
Returns the object paired with the specified key if it's present in the cache, otherwise must return null. |
void |
insert(java.lang.Object key,
java.lang.Object o)
Inserts the specified object into the cache following the implemented policy. |
java.lang.Object |
peek(java.lang.Object key)
Returns the object paired with the specified key if it's present in the cache, otherwise must return null. |
void |
remove(java.lang.Object key)
Remove the cached object paired with the specified key. |
int |
size()
Get the size of the cache. |
void |
start()
Starts this cache that is now ready to be used. |
void |
stop()
Stops this cache thus flush()ing all cached objects. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.HashMap m_map
protected LRUCachePolicy.LRUList (src) m_list
protected int m_maxCapacity
protected int m_minCapacity
| Constructor Detail |
public LRUCachePolicy()
create()
public LRUCachePolicy(int min,
int max)
create()| Method Detail |
public void create()
create in interface CachePolicy (src) start(),
destroy()public void start()
start in interface CachePolicy (src) create(),
stop()public void stop()
flush()ing all cached objects. start() will restart the cache.
stop in interface CachePolicy (src) start(),
destroy()public void destroy()
create()ed and
re-start()ed.
destroy in interface CachePolicy (src) create()public java.lang.Object get(java.lang.Object key)
CachePolicy (src) CachePolicy.peek(java.lang.Object) this method not only return whether
the object is present in the cache or not, but also
applies the implemented policy that will "refresh" the cached
object in the cache, because this cached object
was really requested.
get in interface CachePolicy (src) key - the key paired with the objectCachePolicy.peek(java.lang.Object)public java.lang.Object peek(java.lang.Object key)
CachePolicy (src) CachePolicy.get(java.lang.Object).
peek in interface CachePolicy (src) key - the key paired with the objectCachePolicy.get(java.lang.Object)
public void insert(java.lang.Object key,
java.lang.Object o)
CachePolicy (src)
insert in interface CachePolicy (src) key - the key paired with the objecto - the object to cacheCachePolicy.remove(java.lang.Object)public void remove(java.lang.Object key)
CachePolicy (src)
remove in interface CachePolicy (src) key - the key paired with the objectCachePolicy.insert(java.lang.Object, java.lang.Object)public void flush()
CachePolicy (src)
flush in interface CachePolicy (src) public int size()
CachePolicy (src)
size in interface CachePolicy (src) protected LRUCachePolicy.LRUList (src) createList()
protected void ageOut(LRUCachePolicy.LRUCacheEntry (src) entry)
protected void cacheMiss()
protected LRUCachePolicy.LRUCacheEntry (src) createCacheEntry(java.lang.Object key,
java.lang.Object value)
|
||||||||||
| PREV CLASS (src) NEXT CLASS (src) | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||