Class Node<K,V>
java.lang.Object
com.github.benmanes.caffeine.cache.Node<K,V>
- All Implemented Interfaces:
AccessOrderDeque.AccessOrder<Node<K,V>>, WriteOrderDeque.WriteOrder<Node<K, V>>
abstract class Node<K,V>
extends Object
implements AccessOrderDeque.AccessOrder<Node<K,V>>, WriteOrderDeque.WriteOrder<Node<K,V>>
An entry in the cache containing the key, value, weight, access, and write metadata. The key
or value may be held weakly or softly requiring identity comparison.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancasVariableTime(long expect, long update) Atomically sets the variable time to the given updated value if the current value equals the expected value and returns if the update was successful.booleancasWriteTime(long expect, long update) Atomically sets the write time to the given updated value if the current value equals the expected value and returns if the update was successful.abstract booleancontainsValue(@NonNull Object value) Returnstrueif the given objects are considered equivalent.abstract voiddie()Sets the node to the dead state.longReturns the time that this entry was last accessed, in ns.abstract @Nullable KgetKey()Return the key ornullif it has been reclaimed by the garbage collector.abstract @NonNull ObjectReturns the reference that the cache is holding the entry by.Retrieves the next element or null if either the element is unlinked or the last element on the deque.Retrieves the next element or null if either the element is unlinked or the last element on the deque.@NonNegative intReturns the weight of this entry from the policy's perspective.Retrieves the previous element or null if either the element is unlinked or the first element on the deque.Retrieves the previous element or null if either the element is unlinked or the first element on the deque.intReturns the queue that the entry's resides in (window, probation, or protected).abstract @Nullable VgetValue()Return the value ornullif it has been reclaimed by the garbage collector.abstract @NonNull ObjectReturns the reference to the value.longReturns the variable expiration time, in nanoseconds.@NonNegative intReturns the weight of this entry from the entry's perspective.longReturns the time that this entry was last written, in ns.booleanReturns if the entry is in the Main space's probation queue.booleanReturns if the entry is in the Main space's protected queue.booleaninWindow()Returns if the entry is in the Window or Main space.abstract booleanisAlive()If the entry is available in the hash-table and page replacement policy.abstract booleanisDead()If the entry was removed from the hash-table and the page replacement policy.abstract booleanIf the entry was removed from the hash-table and is awaiting removal from the page replacement policy.voidSets the status to the Main space's probation queue.voidSets the status to the Main space's protected queue.voidSets the status to the Window queue.abstract voidretire()Sets the node to the retired state.voidsetAccessTime(long time) Sets the access time in nanoseconds.voidsetNextInAccessOrder(@Nullable Node<K, V> next) Sets the next element or null if there is no link.voidsetNextInVariableOrder(@Nullable Node<K, V> prev) voidsetNextInWriteOrder(@Nullable Node<K, V> next) Sets the next element or null if there is no link.voidsetPolicyWeight(@NonNegative int weight) Sets the weight from the policy's perspective.voidsetPreviousInAccessOrder(@Nullable Node<K, V> prev) Sets the previous element or null if there is no link.voidsetPreviousInVariableOrder(@Nullable Node<K, V> prev) voidsetPreviousInWriteOrder(@Nullable Node<K, V> prev) Sets the previous element or null if there is no link.voidsetQueueType(int queueType) Set queue that the entry resides in (window, probation, or protected).abstract voidsetValue(@NonNull V value, @Nullable ReferenceQueue<V> referenceQueue) Sets the value, which may be held strongly, weakly, or softly.voidsetVariableTime(long time) Sets the variable expiration time in nanoseconds.voidsetWeight(@NonNegative int weight) Sets the weight from the entry's perspective.voidsetWriteTime(long time) Sets the write time in nanoseconds.final StringtoString()
-
Field Details
-
WINDOW
public static final int WINDOW- See Also:
-
PROBATION
public static final int PROBATION- See Also:
-
PROTECTED
public static final int PROTECTED- See Also:
-
-
Constructor Details
-
Node
Node()
-
-
Method Details
-
getKey
Return the key ornullif it has been reclaimed by the garbage collector. -
getKeyReference
Returns the reference that the cache is holding the entry by. This is either the key if strongly held or aWeakReferenceto that key. -
getValue
Return the value ornullif it has been reclaimed by the garbage collector. -
getValueReference
-
setValue
Sets the value, which may be held strongly, weakly, or softly. This update may be set lazily and rely on the memory fence when the lock is released. -
containsValue
Returnstrueif the given objects are considered equivalent. A strongly held value is compared by equality and a weakly or softly held value is compared by identity. -
getWeight
public @NonNegative int getWeight()Returns the weight of this entry from the entry's perspective. -
setWeight
public void setWeight(@NonNegative int weight) Sets the weight from the entry's perspective. -
getPolicyWeight
public @NonNegative int getPolicyWeight()Returns the weight of this entry from the policy's perspective. -
setPolicyWeight
public void setPolicyWeight(@NonNegative int weight) Sets the weight from the policy's perspective. -
isAlive
public abstract boolean isAlive()If the entry is available in the hash-table and page replacement policy. -
isRetired
public abstract boolean isRetired()If the entry was removed from the hash-table and is awaiting removal from the page replacement policy. -
isDead
public abstract boolean isDead()If the entry was removed from the hash-table and the page replacement policy. -
retire
public abstract void retire()Sets the node to the retired state. -
die
public abstract void die()Sets the node to the dead state. -
getVariableTime
public long getVariableTime()Returns the variable expiration time, in nanoseconds. -
setVariableTime
public void setVariableTime(long time) Sets the variable expiration time in nanoseconds. This update may be set lazily and rely on the memory fence when the lock is released. -
casVariableTime
public boolean casVariableTime(long expect, long update) Atomically sets the variable time to the given updated value if the current value equals the expected value and returns if the update was successful. -
getPreviousInVariableOrder
-
setPreviousInVariableOrder
-
getNextInVariableOrder
-
setNextInVariableOrder
-
inWindow
public boolean inWindow()Returns if the entry is in the Window or Main space. -
inMainProbation
public boolean inMainProbation()Returns if the entry is in the Main space's probation queue. -
inMainProtected
public boolean inMainProtected()Returns if the entry is in the Main space's protected queue. -
makeWindow
public void makeWindow()Sets the status to the Window queue. -
makeMainProbation
public void makeMainProbation()Sets the status to the Main space's probation queue. -
makeMainProtected
public void makeMainProtected()Sets the status to the Main space's protected queue. -
getQueueType
public int getQueueType()Returns the queue that the entry's resides in (window, probation, or protected). -
setQueueType
public void setQueueType(int queueType) Set queue that the entry resides in (window, probation, or protected). -
getAccessTime
public long getAccessTime()Returns the time that this entry was last accessed, in ns. -
setAccessTime
public void setAccessTime(long time) Sets the access time in nanoseconds. This update may be set lazily and rely on the memory fence when the lock is released. -
getPreviousInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrderRetrieves the previous element or null if either the element is unlinked or the first element on the deque.- Specified by:
getPreviousInAccessOrderin interfaceAccessOrderDeque.AccessOrder<K>
-
setPreviousInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrderSets the previous element or null if there is no link.- Specified by:
setPreviousInAccessOrderin interfaceAccessOrderDeque.AccessOrder<K>
-
getNextInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrderRetrieves the next element or null if either the element is unlinked or the last element on the deque.- Specified by:
getNextInAccessOrderin interfaceAccessOrderDeque.AccessOrder<K>
-
setNextInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrderSets the next element or null if there is no link.- Specified by:
setNextInAccessOrderin interfaceAccessOrderDeque.AccessOrder<K>
-
getWriteTime
public long getWriteTime()Returns the time that this entry was last written, in ns. -
setWriteTime
public void setWriteTime(long time) Sets the write time in nanoseconds. This update may be set lazily and rely on the memory fence when the lock is released. -
casWriteTime
public boolean casWriteTime(long expect, long update) Atomically sets the write time to the given updated value if the current value equals the expected value and returns if the update was successful. -
getPreviousInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrderRetrieves the previous element or null if either the element is unlinked or the first element on the deque.- Specified by:
getPreviousInWriteOrderin interfaceWriteOrderDeque.WriteOrder<K>
-
setPreviousInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrderSets the previous element or null if there is no link.- Specified by:
setPreviousInWriteOrderin interfaceWriteOrderDeque.WriteOrder<K>
-
getNextInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrderRetrieves the next element or null if either the element is unlinked or the last element on the deque.- Specified by:
getNextInWriteOrderin interfaceWriteOrderDeque.WriteOrder<K>
-
setNextInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrderSets the next element or null if there is no link.- Specified by:
setNextInWriteOrderin interfaceWriteOrderDeque.WriteOrder<K>
-
toString
-