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 TypeMethodDescriptionboolean
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.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.abstract boolean
containsValue
(@NonNull Object value) Returnstrue
if the given objects are considered equivalent.abstract void
die()
Sets the node to the dead state.long
Returns the time that this entry was last accessed, in ns.abstract @Nullable K
getKey()
Return the key ornull
if it has been reclaimed by the garbage collector.abstract @NonNull Object
Returns 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.@org.checkerframework.checker.index.qual.NonNegative int
Returns 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.int
Returns the queue that the entry's resides in (window, probation, or protected).abstract @Nullable V
getValue()
Return the value ornull
if it has been reclaimed by the garbage collector.abstract @NonNull Object
Returns the reference to the value.long
Returns the variable expiration time, in nanoseconds.@org.checkerframework.checker.index.qual.NonNegative int
Returns the weight of this entry from the entry's perspective.long
Returns the time that this entry was last written, in ns.boolean
Returns if the entry is in the Main space's probation queue.boolean
Returns if the entry is in the Main space's protected queue.boolean
inWindow()
Returns if the entry is in the Window or Main space.abstract boolean
isAlive()
If the entry is available in the hash-table and page replacement policy.abstract boolean
isDead()
If the entry was removed from the hash-table and the page replacement policy.abstract boolean
If the entry was removed from the hash-table and is awaiting removal from the page replacement policy.void
Sets the status to the Main space's probation queue.void
Sets the status to the Main space's protected queue.void
Sets the status to the Window queue.abstract void
retire()
Sets the node to the retired state.void
setAccessTime
(long time) Sets the access time in nanoseconds.void
setNextInAccessOrder
(@Nullable Node<K, V> next) Sets the next element or null if there is no link.void
setNextInVariableOrder
(@Nullable Node<K, V> prev) void
setNextInWriteOrder
(@Nullable Node<K, V> next) Sets the next element or null if there is no link.void
setPolicyWeight
(@org.checkerframework.checker.index.qual.NonNegative int weight) Sets the weight from the policy's perspective.void
setPreviousInAccessOrder
(@Nullable Node<K, V> prev) Sets the previous element or null if there is no link.void
setPreviousInVariableOrder
(@Nullable Node<K, V> prev) void
setPreviousInWriteOrder
(@Nullable Node<K, V> prev) Sets the previous element or null if there is no link.void
setQueueType
(int queueType) Set queue that the entry resides in (window, probation, or protected).abstract void
setValue
(@NonNull V value, @Nullable ReferenceQueue<V> referenceQueue) Sets the value, which may be held strongly, weakly, or softly.void
setVariableTime
(long time) Sets the variable expiration time in nanoseconds.void
setWeight
(@org.checkerframework.checker.index.qual.NonNegative int weight) Sets the weight from the entry's perspective.void
setWriteTime
(long time) Sets the write time in nanoseconds.final String
toString()
-
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 ornull
if 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 aWeakReference
to that key. -
getValue
Return the value ornull
if it has been reclaimed by the garbage collector. -
getValueReference
Returns the reference to the value. This is either the value if strongly held or aReference
to that value. -
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
Returnstrue
if 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 @org.checkerframework.checker.index.qual.NonNegative int getWeight()Returns the weight of this entry from the entry's perspective. -
setWeight
public void setWeight(@org.checkerframework.checker.index.qual.NonNegative int weight) Sets the weight from the entry's perspective. -
getPolicyWeight
public @org.checkerframework.checker.index.qual.NonNegative int getPolicyWeight()Returns the weight of this entry from the policy's perspective. -
setPolicyWeight
public void setPolicyWeight(@org.checkerframework.checker.index.qual.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.AccessOrder
Retrieves the previous element or null if either the element is unlinked or the first element on the deque.- Specified by:
getPreviousInAccessOrder
in interfaceAccessOrderDeque.AccessOrder<K>
-
setPreviousInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrder
Sets the previous element or null if there is no link.- Specified by:
setPreviousInAccessOrder
in interfaceAccessOrderDeque.AccessOrder<K>
-
getNextInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrder
Retrieves the next element or null if either the element is unlinked or the last element on the deque.- Specified by:
getNextInAccessOrder
in interfaceAccessOrderDeque.AccessOrder<K>
-
setNextInAccessOrder
Description copied from interface:AccessOrderDeque.AccessOrder
Sets the next element or null if there is no link.- Specified by:
setNextInAccessOrder
in 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.WriteOrder
Retrieves the previous element or null if either the element is unlinked or the first element on the deque.- Specified by:
getPreviousInWriteOrder
in interfaceWriteOrderDeque.WriteOrder<K>
-
setPreviousInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrder
Sets the previous element or null if there is no link.- Specified by:
setPreviousInWriteOrder
in interfaceWriteOrderDeque.WriteOrder<K>
-
getNextInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrder
Retrieves the next element or null if either the element is unlinked or the last element on the deque.- Specified by:
getNextInWriteOrder
in interfaceWriteOrderDeque.WriteOrder<K>
-
setNextInWriteOrder
Description copied from interface:WriteOrderDeque.WriteOrder
Sets the next element or null if there is no link.- Specified by:
setNextInWriteOrder
in interfaceWriteOrderDeque.WriteOrder<K>
-
toString
-