org.jboss.cache.eviction
Class MRUAlgorithm

java.lang.Object
  extended by org.jboss.cache.eviction.BaseEvictionAlgorithm
      extended by org.jboss.cache.eviction.MRUAlgorithm
All Implemented Interfaces:
EvictionAlgorithm

public class MRUAlgorithm
extends BaseEvictionAlgorithm

Most Recently Used Algorithm.

This algorithm will evict the most recently used cache entries from cache.

Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/ EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.

Version:
$Revision: 1.4 $
Author:
Daniel Huang (dhuang@jboss.org)

Field Summary
 
Fields inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm
evictionQueue, recycleQueue, region
 
Constructor Summary
MRUAlgorithm()
           
 
Method Summary
protected  void processVisitedNodes(Fqn fqn)
          Visit a node in cache.
protected  EvictionQueue setupEvictionQueue(Region region)
          This method will create an EvictionQueue implementation and prepare it for use.
protected  boolean shouldEvictNode(NodeEntry ne)
          This method will check whether the given node should be evicted or not.
 
Methods inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm
emptyRecycleQueue, evict, evictCacheNode, getEvictionQueue, initialize, isNodeInUseAndNotTimedOut, process, processAddedElement, processAddedNodes, processMarkInUseNodes, processQueues, processRemovedElement, processRemovedNodes, processUnmarkInUseNodes, prune, resetEvictionQueue, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MRUAlgorithm

public MRUAlgorithm()
Method Detail

setupEvictionQueue

protected EvictionQueue setupEvictionQueue(Region region)
                                    throws EvictionException
Description copied from class: BaseEvictionAlgorithm
This method will create an EvictionQueue implementation and prepare it for use.

Specified by:
setupEvictionQueue in class BaseEvictionAlgorithm
Parameters:
region - MarshRegion to setup an eviction queue for.
Returns:
The created EvictionQueue to be used as the eviction queue for this algorithm.
Throws:
EvictionException
See Also:
EvictionQueue

shouldEvictNode

protected boolean shouldEvictNode(NodeEntry ne)
Description copied from class: BaseEvictionAlgorithm
This method will check whether the given node should be evicted or not.

Specified by:
shouldEvictNode in class BaseEvictionAlgorithm
Parameters:
ne - NodeEntry to test eviction for.
Returns:
True if the given node should be evicted. False if the given node should not be evicted.

processVisitedNodes

protected void processVisitedNodes(Fqn fqn)
                            throws EvictionException
Description copied from class: BaseEvictionAlgorithm
Visit a node in cache.

This method will update the numVisits and modifiedTimestamp properties of the Node. These properties are used as statistics to determine eviction (LRU, LFU, MRU, etc..)

*Note* that this method updates Node Entries by reference and does not put them back into the queue. For some sorted collections, a remove, and a re-add is required to maintain the sorted order of the elements.

Overrides:
processVisitedNodes in class BaseEvictionAlgorithm
Parameters:
fqn - FQN of the visited node.
Throws:
EvictionException