org.shiftone.cache.policy.lfu
Class LfuCache

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

class LfuCache
extends AbstractPolicyCache
implements ReapableCache

Class LfuCache

Version:
$Revision: 1.12 $
Author:
Jeff Drost

Field Summary
 
Fields inherited from class org.shiftone.cache.policy.AbstractPolicyCache
SHRINK_DIV
 
Constructor Summary
(package private) LfuCache(java.lang.String name, long timeoutMilliSeconds, int maxSize)
           
  LfuCache(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 cacheNode)
          Remove a node from the cache.
(package private)  java.lang.String dumpFifoKeys()
           
(package private)  java.lang.String dumpLfuKeys()
           
protected  CacheNode findNodeByKey(java.lang.Object key)
          Method findNodeByKey
protected  CacheNode getLeastValuableNode()
          This method will execute the cache's onEviction strategy.
protected  LinkedList getLowestNonEmptyLru()
           
protected  LinkedList lru(int numUsageIndex)
           
 void removeExpiredElements()
          Method removeExpiredElements
protected  void revalueNode(CacheNode cacheNode)
          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

LfuCache

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

LfuCache

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

lru

protected final LinkedList lru(int numUsageIndex)

size

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

Specified by:
size in interface Cache

findNodeByKey

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

Specified by:
findNodeByKey in class AbstractPolicyCache

revalueNode

protected void revalueNode(CacheNode cacheNode)
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 cacheNode)
Description copied from class: AbstractPolicyCache
Remove a node from the cache.

Specified by:
delete in class AbstractPolicyCache

getLowestNonEmptyLru

protected LinkedList getLowestNonEmptyLru()

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

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

removeExpiredElements

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

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

dumpLfuKeys

java.lang.String dumpLfuKeys()

dumpFifoKeys

java.lang.String dumpFifoKeys()