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:
Serializable
,Comparable<Cache.ConcurrentLinkedHashMap.EvictionPolicy>
,java.lang.constant.Constable
- Enclosing class:
- Cache.ConcurrentLinkedHashMap<K,
V>
public static enum Cache.ConcurrentLinkedHashMap.EvictionPolicy
extends Enum<Cache.ConcurrentLinkedHashMap.EvictionPolicy>
The replacement policy to apply to determine which entry to discard to when the capacity has been reached.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionEvicts entries based on insertion order.Evicts entries based on how recently they are used, with the least recent evicted first.Evicts entries based on insertion order, but gives an entry a "second chance" if it has been requested recently. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) 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.(package private) 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.(package private) <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.Returns the enum constant of this type with the specified name.values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
FIFO
Evicts entries based on insertion order. -
SECOND_CHANCE
Evicts entries based on insertion order, but gives an entry a "second chance" if it has been requested recently. -
LRU
Evicts entries based on how recently they are used, with the least recent evicted first.
-
-
Constructor Details
-
EvictionPolicy
private EvictionPolicy()
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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 nameNullPointerException
- 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
-