org.shiftone.cache.policy.lru
Class LruCache

java.lang.Object
  extended byorg.shiftone.cache.policy.AbstractPolicyCache
      extended byorg.shiftone.cache.policy.lru.LruCache
All Implemented Interfaces:
Cache, ReapableCache

class LruCache
extends AbstractPolicyCache
implements ReapableCache

Class LruCache

Version:
$Revision: 1.11 $
Author:
Jeff Drost

Field Summary
 
Fields inherited from class org.shiftone.cache.policy.AbstractPolicyCache
SHRINK_DIV
 
Constructor Summary
(package private) LruCache(java.lang.String name, long timeoutMilliSeconds, int maxSize)
           
(package private) LruCache(java.lang.String name, long timeoutMilliSeconds, int maxSize, EvictionListener evictionListener)
           
 
Method Summary
protected  CacheNode createNode(java.lang.Object key, java.lang.Object cacheObject)
          Create a new node.
protected  void delete(CacheNode node)
          Remove a node from the cache.
(package private)  java.lang.String dumpFifoKeys()
           
(package private)  java.lang.String dumpLruKeys()
           
protected  CacheNode findNodeByKey(java.lang.Object key)
          Method findNodeByKey
protected  CacheNode getLeastValuableNode()
          This method will execute the cache's onEviction strategy.
 void removeExpiredElements()
          Method removeExpiredElements
protected  void revalueNode(CacheNode node)
          Update the node's value.
 int size()
          The number of key/value pares in the cache
 
Methods inherited from class org.shiftone.cache.policy.AbstractPolicyCache
addObject, clear, getMaxSize, getName, getObject, getTimeoutMilliSeconds, remove, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.shiftone.cache.Cache
addObject, clear, getObject, remove
 

Constructor Detail

LruCache

LruCache(java.lang.String name,
         long timeoutMilliSeconds,
         int maxSize)

LruCache

LruCache(java.lang.String name,
         long timeoutMilliSeconds,
         int maxSize,
         EvictionListener evictionListener)
Method Detail

findNodeByKey

protected CacheNode findNodeByKey(java.lang.Object key)
Description copied from class: AbstractPolicyCache
Method findNodeByKey

Specified by:
findNodeByKey in class AbstractPolicyCache

size

public int size()
Description copied from interface: Cache
The number of key/value pares in the cache

Specified by:
size in interface Cache

revalueNode

protected void revalueNode(CacheNode node)
Description copied from class: AbstractPolicyCache
Update the node's value. This is done immediately after the node is retrieved.

Specified by:
revalueNode in class AbstractPolicyCache

delete

protected void delete(CacheNode node)
Description copied from class: AbstractPolicyCache
Remove a node from the cache.

Specified by:
delete in class AbstractPolicyCache

getLeastValuableNode

protected CacheNode getLeastValuableNode()
Description copied from class: AbstractPolicyCache
This method will execute the cache's onEviction strategy. If this method is called, there will be at least one element in the cache to remove. The method itself does not need to check for the existance of a element.

This method is only called by shrinkToSize();

Specified by:
getLeastValuableNode in class AbstractPolicyCache

removeExpiredElements

public void removeExpiredElements()
Description copied from interface: ReapableCache
Method removeExpiredElements

Specified by:
removeExpiredElements in interface ReapableCache
Specified by:
removeExpiredElements in class AbstractPolicyCache

createNode

protected CacheNode createNode(java.lang.Object key,
                               java.lang.Object cacheObject)
Description copied from class: AbstractPolicyCache
Create a new node.

Specified by:
createNode in class AbstractPolicyCache

dumpLruKeys

java.lang.String dumpLruKeys()

dumpFifoKeys

java.lang.String dumpFifoKeys()