Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.cache.eviction
Class LFUAlgorithm

    java.lang.Object
      org.jboss.cache.eviction.BaseEvictionAlgorithm
          org.jboss.cache.eviction.BaseSortedEvictionAlgorithm
              org.jboss.cache.eviction.LFUAlgorithm

All Implemented Interfaces:
  EvictionAlgorithm

    public class LFUAlgorithm

extends BaseSortedEvictionAlgorithm
implements EvictionAlgorithm

Least Frequently Used algorithm for cache eviction. Note that this algorithm is not thread-safe.

This algorithm relies on maxNodes and minNodes to operate correctly. Eviction takes place using Least Frequently Used algorithm. A node A that is used less than a node B is evicted sooner.

The minNodes property defines a threshold for eviction. If minNodes = 100, the LFUAlgorithm will not evict the cache to anything less than 100 elements still left in cache. The maxNodes property defines the maximum number of nodes the cache will accept before eviction. maxNodes = 0 means that this region is unbounded. minNodes = 0 means that the eviction queue will attempt to bring the cache of this region to 0 elements (evict all elements) whenever it is run.

This algorithm uses a sorted eviction queue. The eviction queue is sorted in ascending order based on the number of times a node is visited. The more frequently a node is visited, the less likely it will be evicted.

Version:
  $Revision: 1.4 $
Author:
  Daniel Huang - dhuang@jboss.org 10/2005

Field Summary

Fields inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm
`evictionQueue, recycleQueue, region`

Constructor Summary
`LFUAlgorithm()`

Method Summary
`protected void` | `prune()`
`protected EvictionQueue` | `setupEvictionQueue(Region region)` Will create a LFUQueue to be used as the underlying eviction queue.
`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.BaseSortedEvictionAlgorithm
`process, processQueues, resortEvictionQueue`

Methods inherited from class org.jboss.cache.eviction.BaseEvictionAlgorithm
`emptyRecycleQueue, evict, evictCacheNode, getEvictionQueue, initialize, isNodeInUseAndNotTimedOut, processAddedElement, processAddedNodes, processMarkInUseNodes, processRemovedElement, processRemovedNodes, processUnmarkInUseNodes, processVisitedNodes, resetEvictionQueue`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.jboss.cache.eviction.EvictionAlgorithm
`getEvictionQueue, process, resetEvictionQueue`

Constructor Detail

### LFUAlgorithm

    public LFUAlgorithm()

Method Detail

### 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.

### setupEvictionQueue

    protected EvictionQueue setupEvictionQueue(Region region)
                                        throws EvictionException

  Will create a LFUQueue to be used as the underlying eviction queue.

  Specified by:
    `setupEvictionQueue` in class `BaseEvictionAlgorithm`
  Parameters:
    `region` - Region to create the eviction queue for.
  Returns:
    The created LFUQueue.
  Throws:
    `EvictionException`
  See Also:
    `EvictionQueue`

### prune

    protected void prune()
                  throws EvictionException

  Overrides:
    `prune` in class `BaseEvictionAlgorithm`
  Throws:
    `EvictionException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1998-2005 JBoss Inc . All Rights Reserved.