public class Entry<K,T> extends Object implements CacheEntry<K,T>, StorageEntry, ExaminationEntry<K,T>
When an entry is present and its value is updated, the entry objects stays the same. The entry object is used for locking and coordination of all concurrent accesses to it.
The entry is only used as CacheEntry
directly and handed to the
application when it is locked and the values are stable, that is for example
when the loader is called.
Modifier and Type | Field and Description |
---|---|
Entry<K,T> |
another
Hash implementation: Link to another entry in the same hash table slot when the hash code collides.
|
static int |
EXPIRY_TIME_MIN
A value greater as means it is a time value.
|
int |
hashCode
Hash implementation: the calculated, modified hash code, retrieved from the key when the entry is
inserted in the cache
|
long |
hitCnt
Hit counter.
|
protected static org.cache2k.core.CompactEntry.InitialValueInEntryNeverReturned |
INITIAL_VALUE |
K |
key |
Entry |
next
Lru list: pointer to next element or list head
|
protected long |
nextRefreshTime
Contains the next time a refresh has to occur, or if no background refresh is configured, when the entry
is expired.
|
Entry |
prev
Lru list: pointer to previous element or list head
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkCyclicListIntegrity(Entry e) |
void |
ensureAbort(boolean _finished)
Make sure entry processing is properly finished, otherwise threads waiting for
an entry get stuck.
|
boolean |
equalsValue(T v) |
long |
getCreatedOrUpdated()
Used for the storage interface.
|
static int |
getCyclicListEntryCount(Entry e) |
long |
getEntryExpiryTime()
Deprecated.
Always returns 0, only to fulfill the
StorageEntry interface |
Throwable |
getException() |
K |
getKey()
Key of the stored entry
|
long |
getLastModification() |
static int |
getListEntryCount(Entry _head) |
long |
getNextRefreshTime() |
<X> X |
getPiggyBack(Class<X> _class) |
int |
getProcessingState() |
long |
getRefreshProbationNextRefreshTime() |
ExceptionInformation |
getSuppressedLoadExceptionInformation() |
SimpleTask |
getTask() |
T |
getValue()
Deprecated.
|
long |
getValueExpiryTime()
Expiry time or 0.
|
T |
getValueOrException()
Used for the storage interface.
|
boolean |
hasFreshData(InternalClock t)
Returns true if the entry has a valid value and is fresh / not expired.
|
boolean |
hasFreshData(long now,
long _nextRefreshTime) |
static <E extends Entry> |
insertAfterHeadCyclicList(E _head,
E e)
Insert X into A B C, yields: A X B C.
|
static void |
insertInList(Entry _head,
Entry e) |
static <E extends Entry> |
insertIntoHeadCyclicList(E _head,
E e)
Insert element at the head of the list
|
static <E extends Entry> |
insertIntoTailCyclicList(E _head,
E e) |
boolean |
isDataValid()
The entry value was fetched and is valid, which means it can be
returned by the cache.
|
boolean |
isDirty()
Memory entry needs to be send to the storage.
|
boolean |
isExpired()
The entry expired, still in the cache and subject to removal from the cache
if
HeapCache.hasKeepAfterExpired() is false. |
boolean |
isGettingRefresh() |
boolean |
isGone()
The entry is not present in the heap any more and was evicted, expired or removed.
|
boolean |
isHot() |
boolean |
isNotYetInsertedInReplacementList()
Entry was not inserted into the replacement list AND not removed from replacement list.
|
boolean |
isProcessing() |
boolean |
isReadNonValid()
Storage was checked, no data available
|
boolean |
isRemovedFromReplacementList()
Check that this entry is removed from the list, may be used in assertions.
|
boolean |
isStable()
Entry is locked and does not need synchronization to read values consistently
|
boolean |
isVirgin()
Initial state of an entry.
|
static <E extends Entry> |
moveToFront(E _head,
E e) |
boolean |
needsTimeCheck() |
void |
nextProcessingStep(int ps)
Switch to another processing state that is other then done.
|
void |
processingDone()
Set processing state to done and notify all that wait for
processing this entry.
|
void |
removedFromList()
Reset next as a marker for
isRemovedFromReplacementList() |
static <E extends Entry> |
removeFromCyclicList(E _head,
E e) |
static Entry |
removeFromCyclicList(Entry e) |
static void |
removeFromList(Entry e) |
void |
resetDirty() |
void |
resetSuppressedLoadExceptionInformation()
If the entry carries information about a suppressed exception, clear it.
|
void |
setExpiredState()
Entry is kept in the cache but has expired
|
void |
setGone() |
void |
setHot(boolean f) |
void |
setLastModification(long t)
Set modification time and marks entry as dirty.
|
void |
setLastModificationFromStorage(long t) |
void |
setNextRefreshTime(long _nextRefreshTime) |
void |
setRefreshProbationNextRefreshTime(long nrt) |
void |
setSuppressedLoadExceptionInformation(ExceptionInformation w) |
void |
setTask(SimpleTask v) |
void |
setValueOrException(T _valueOrException) |
Entry |
shortCircuit() |
void |
startProcessing()
Starts long operation on entry.
|
void |
startProcessing(int ps) |
String |
toString() |
String |
toString(HeapCache c) |
void |
waitForProcessing() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getException, getValue
getValueOrException
getValueOrException
public static final int EXPIRY_TIME_MIN
public Entry next
public Entry prev
protected static final org.cache2k.core.CompactEntry.InitialValueInEntryNeverReturned INITIAL_VALUE
protected volatile long nextRefreshTime
public final K key
public final int hashCode
HeapCache.modifiedHash(int)
public Entry<K,T> another
public long hitCnt
HeapCache.recordHit(Entry)
public Entry(K _key, int _hashCode)
public Entry()
public void setLastModification(long t)
public boolean isDirty()
public void setLastModificationFromStorage(long t)
public void resetDirty()
public long getLastModification()
getLastModification
in interface CacheEntry<K,T>
getLastModification
in interface ExaminationEntry<K,T>
public int getProcessingState()
public void startProcessing()
public void startProcessing(int ps)
public void nextProcessingStep(int ps)
public void processingDone()
public long getNextRefreshTime()
public void setNextRefreshTime(long _nextRefreshTime)
public void ensureAbort(boolean _finished)
Usually no exceptions happens, but the CacheClosedException is happening out of order and stops processing to properly finish.
public boolean isProcessing()
public boolean isStable()
ExaminationEntry
isStable
in interface ExaminationEntry<K,T>
public void waitForProcessing()
public boolean isGettingRefresh()
public final void removedFromList()
isRemovedFromReplacementList()
public boolean isRemovedFromReplacementList()
public boolean isNotYetInsertedInReplacementList()
public Entry shortCircuit()
public final boolean isVirgin()
public final boolean isDataValid()
Even if this is true, the data may be expired. Use hasFreshData() to make sure to get not expired data.
public final boolean hasFreshData(InternalClock t)
public final boolean hasFreshData(long now, long _nextRefreshTime)
public boolean isReadNonValid()
public void setExpiredState()
public boolean isExpired()
HeapCache.hasKeepAfterExpired()
is false.public void setGone()
public boolean isGone()
public boolean needsTimeCheck()
public boolean isHot()
public void setHot(boolean f)
public K getKey()
StorageEntry
getKey
in interface CacheEntry<K,T>
getKey
in interface ExaminationEntry<K,T>
getKey
in interface StorageEntry
getKey
in interface SimpleCacheEntry<K,T>
public long getValueExpiryTime()
getValueExpiryTime
in interface StorageEntry
public long getCreatedOrUpdated()
getCreatedOrUpdated
in interface StorageEntry
StorageEntry
public long getEntryExpiryTime()
StorageEntry
interfacegetEntryExpiryTime
in interface StorageEntry
StorageEntry
public SimpleTask getTask()
public <X> X getPiggyBack(Class<X> _class)
public void setTask(SimpleTask v)
public void setSuppressedLoadExceptionInformation(ExceptionInformation w)
public void resetSuppressedLoadExceptionInformation()
public ExceptionInformation getSuppressedLoadExceptionInformation()
public void setRefreshProbationNextRefreshTime(long nrt)
public long getRefreshProbationNextRefreshTime()
public static void removeFromList(Entry e)
public static final int getListEntryCount(Entry _head)
public static final <E extends Entry> void moveToFront(E _head, E e)
public static final <E extends Entry> E insertIntoTailCyclicList(E _head, E e)
public static final <E extends Entry> E insertAfterHeadCyclicList(E _head, E e)
public static final <E extends Entry> E insertIntoHeadCyclicList(E _head, E e)
public static <E extends Entry> E removeFromCyclicList(E _head, E e)
public static int getCyclicListEntryCount(Entry e)
public static boolean checkCyclicListIntegrity(Entry e)
public void setValueOrException(T _valueOrException)
public Throwable getException()
public boolean equalsValue(T v)
public T getValue()
public T getValueOrException()
StorageEntry
cache2k API documentation. Copyright © 2000–2018 headissue GmbH, Munich.