Package gw.util.concurrent
Enum Cache.ConcurrentLinkedHashMap.EvictionPolicy
- java.lang.Object
-
- java.lang.Enum<Cache.ConcurrentLinkedHashMap.EvictionPolicy>
-
- gw.util.concurrent.Cache.ConcurrentLinkedHashMap.EvictionPolicy
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<Cache.ConcurrentLinkedHashMap.EvictionPolicy>
- Enclosing class:
- Cache.ConcurrentLinkedHashMap<K,V>
public static enum Cache.ConcurrentLinkedHashMap.EvictionPolicy extends java.lang.Enum<Cache.ConcurrentLinkedHashMap.EvictionPolicy>
The replacement policy to apply to determine which entry to discard to when the capacity has been reached.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description FIFOEvicts entries based on insertion order.LRUEvicts entries based on how recently they are used, with the least recent evicted first.SECOND_CHANCEEvicts entries based on insertion order, but gives an entry a "second chance" if it has been requested recently.
-
Constructor Summary
Constructors Modifier Constructor Description privateEvictionPolicy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract <K,V>
booleanonEvict(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.ConcurrentLinkedHashMap.Node<K,V> node)Determines whether to evict the node at the head of the list.(package private) abstract <K,V>
voidonGet(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.ConcurrentLinkedHashMap.Node<K,V> node)Performs any operations required by the policy after a node was successfully retrieved.(package private) <K,V>
voidonRemove(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.ConcurrentLinkedHashMap.Node<K,V> node)Expires a node so that, for all intents and purposes, it is a dead on the list.static Cache.ConcurrentLinkedHashMap.EvictionPolicyvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static Cache.ConcurrentLinkedHashMap.EvictionPolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
FIFO
public static final Cache.ConcurrentLinkedHashMap.EvictionPolicy FIFO
Evicts entries based on insertion order.
-
SECOND_CHANCE
public static final Cache.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 Cache.ConcurrentLinkedHashMap.EvictionPolicy LRU
Evicts entries based on how recently they are used, with the least recent evicted first.
-
-
Method Detail
-
values
public static Cache.ConcurrentLinkedHashMap.EvictionPolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Cache.ConcurrentLinkedHashMap.EvictionPolicy c : Cache.ConcurrentLinkedHashMap.EvictionPolicy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Cache.ConcurrentLinkedHashMap.EvictionPolicy valueOf(java.lang.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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
onGet
abstract <K,V> void onGet(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.ConcurrentLinkedHashMap.Node<K,V> node)
Performs any operations required by the policy after a node was successfully retrieved.- Parameters:
map- the map to for this listenernode- the specific node
-
onRemove
<K,V> void onRemove(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.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.- Parameters:
map- the map to for this listenernode- the specific node
-
onEvict
abstract <K,V> boolean onEvict(Cache.ConcurrentLinkedHashMap<K,V> map, Cache.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.- Parameters:
map- the map to for this listenernode- the specific node- Returns:
- whether this node is to be evicted
-
-