org.compass.core.util.concurrent
Enum ConcurrentLinkedHashMap.EvictionPolicy

java.lang.Object
  extended by java.lang.Enum<ConcurrentLinkedHashMap.EvictionPolicy>
      extended by org.compass.core.util.concurrent.ConcurrentLinkedHashMap.EvictionPolicy
All Implemented Interfaces:
Serializable, Comparable<ConcurrentLinkedHashMap.EvictionPolicy>
Enclosing class:
ConcurrentLinkedHashMap<K,V>

public static enum ConcurrentLinkedHashMap.EvictionPolicy
extends Enum<ConcurrentLinkedHashMap.EvictionPolicy>

The replacement policy to apply to determine which entry to discard to when the capacity has been reached.


Enum Constant Summary
FIFO
          Evicts entries based on insertion order.
LRU
          Evicts entries based on how recently they are used, with the least recent evicted first.
SECOND_CHANCE
          Evicts entries based on insertion order, but gives an entry a "second chance" if it has been requested recently.
 
Method Summary
(package private) abstract
<K,V> boolean
onEvict(ConcurrentLinkedHashMap<K,V> map, ConcurrentLinkedHashMap.Node<K,V> node)
          Determines whether to evict the node at the head of the list.
(package private) abstract
<K,V> void
onGet(ConcurrentLinkedHashMap<K,V> map, ConcurrentLinkedHashMap.Node<K,V> node)
          Performs any operations required by the policy after a node was successfully retrieved.
(package private)
<K,V> void
onRemove(ConcurrentLinkedHashMap<K,V> map, ConcurrentLinkedHashMap.Node<K,V> node)
          Expires a node so that, for all intents and purposes, it is a dead on the list.
static ConcurrentLinkedHashMap.EvictionPolicy valueOf(String name)
          Returns the enum constant of this type with the specified name.
static ConcurrentLinkedHashMap.EvictionPolicy[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

FIFO

public static final ConcurrentLinkedHashMap.EvictionPolicy FIFO
Evicts entries based on insertion order.


SECOND_CHANCE

public static final ConcurrentLinkedHashMap.EvictionPolicy SECOND_CHANCE
Evicts entries based on insertion order, but gives an entry a "second chance" if it has been requested recently.


LRU

public static final ConcurrentLinkedHashMap.EvictionPolicy LRU
Evicts entries based on how recently they are used, with the least recent evicted first.

Method Detail

values

public static final ConcurrentLinkedHashMap.EvictionPolicy[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(ConcurrentLinkedHashMap.EvictionPolicy c : ConcurrentLinkedHashMap.EvictionPolicy.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static ConcurrentLinkedHashMap.EvictionPolicy valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name

onGet

abstract <K,V> void onGet(ConcurrentLinkedHashMap<K,V> map,
                          ConcurrentLinkedHashMap.Node<K,V> node)
Performs any operations required by the policy after a node was successfully retrieved.


onRemove

<K,V> void onRemove(ConcurrentLinkedHashMap<K,V> map,
                    ConcurrentLinkedHashMap.Node<K,V> node)
Expires a node so that, for all intents and purposes, it is a dead on the list. The caller of this method should have already removed the node from the mapping so that no key can look it up. When the node reaches the head of the list it will be evicted.


onEvict

abstract <K,V> boolean onEvict(ConcurrentLinkedHashMap<K,V> map,
                               ConcurrentLinkedHashMap.Node<K,V> node)
Determines whether to evict the node at the head of the list. If false, the node is offered to the tail.



Copyright (c) 2004-2009 The Compass Project.