Package com.tangosol.net.cache
Class OldCache.Entry
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.SafeHashMap.Entry
-
- com.tangosol.net.cache.OldCache.Entry
-
- All Implemented Interfaces:
ConfigurableCacheMap.Entry,Serializable,Cloneable,Map.Entry
- Direct Known Subclasses:
LocalCache.Entry
- Enclosing class:
- OldCache
public class OldCache.Entry extends SafeHashMap.Entry implements ConfigurableCacheMap.Entry
A holder for a cached value.- Author:
- cp 2001.04.19
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
-
Fields inherited from class com.tangosol.util.SafeHashMap.Entry
m_eNext, m_nHash, m_oKey, m_oValue
-
-
Constructor Summary
Constructors Constructor Description Entry()Construct the cacheable entry that holds the cached value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcalculateUnits(Object oValue)Calculate a cache cost for the specified object.protected voidcopyFrom(SafeHashMap.Entry entry)Copy this Entry's information from another Entry.protected voiddiscard()Called to inform the Entry that it is no longer used.longgetCreatedMillis()Determine when the cache entry was created.longgetExpiryMillis()Determine when the cache entry will expire, if ever.longgetLastTouchMillis()Determine when the cache entry was last touched.intgetPriority()Calculate a cache priority.intgetTouchCount()Determine the number of times that the cache entry has been touched.intgetUnits()Determine the number of cache units used by this Entry.protected booleanisDiscarded()Determine if this entry has already been discarded from the cache.protected booleanisEvictable()Determine if this entry has been marked as being evictable.booleanisExpired()Determine if the cache entry has expired.protected voidonAdd()This method is invoked when the containing Map has actually added this Entry to itself.protected voidregisterExpiry(long lMillis)Register (or unregister or replace the registration of) this entry for expiry.protected voidresetTouchCount()Reset the number of times that the cache entry has been touched.protected voidscheduleExpiry()Reschedule the cache entry expiration.protected voidsetEvictable(boolean fEvict)Specify that this entry is evictable or not.voidsetExpiryMillis(long lMillis)Specify when the cache entry will expire, or disable expiry.voidsetUnits(int cUnits)Specify the number of cache units used by this Entry.ObjectsetValue(Object oValue)Update the cached value.StringtoString()Render the cache entry as a String.voidtouch()Called each time the entry is accessed or modified.-
Methods inherited from class com.tangosol.util.SafeHashMap.Entry
clone, equals, getKey, getValue, hashCode
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, newHashMap, newHashMap, newHashSet, newHashSet, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Method Detail
-
onAdd
protected void onAdd()
This method is invoked when the containing Map has actually added this Entry to itself.- Overrides:
onAddin classSafeHashMap.Entry
-
setValue
public Object setValue(Object oValue)
Update the cached value.- Specified by:
setValuein interfaceMap.Entry- Overrides:
setValuein classSafeHashMap.Entry- Parameters:
oValue- the new value to cache- Returns:
- the old cache value
-
copyFrom
protected void copyFrom(SafeHashMap.Entry entry)
Copy this Entry's information from another Entry. Sub-classes must implement this method if they add any additional fields.- Overrides:
copyFromin classSafeHashMap.Entry- Parameters:
entry- the entry to copy from
-
getPriority
public int getPriority()
Calculate a cache priority.- Returns:
- a value between 0 and 10, 0 being the highest priority
-
getCreatedMillis
public long getCreatedMillis()
Determine when the cache entry was created.- Returns:
- the date/time value, in millis, when the entry was created
-
touch
public void touch()
Called each time the entry is accessed or modified.- Specified by:
touchin interfaceConfigurableCacheMap.Entry
-
getLastTouchMillis
public long getLastTouchMillis()
Determine when the cache entry was last touched.- Specified by:
getLastTouchMillisin interfaceConfigurableCacheMap.Entry- Returns:
- the date/time value, in millis, when the entry was most recently touched
-
getTouchCount
public int getTouchCount()
Determine the number of times that the cache entry has been touched.- Specified by:
getTouchCountin interfaceConfigurableCacheMap.Entry- Returns:
- the number of times that the cache entry has been touched
-
resetTouchCount
protected void resetTouchCount()
Reset the number of times that the cache entry has been touched. The touch count does not get reset to zero, but rather to a fraction of its former self; this prevents long lived items from gaining an unassailable advantage in the eviction process.- Since:
- Coherence 3.5
-
getExpiryMillis
public long getExpiryMillis()
Determine when the cache entry will expire, if ever.- Specified by:
getExpiryMillisin interfaceConfigurableCacheMap.Entry- Returns:
- the date/time value, in millis, when the entry will (or did) expire; zero indicates no expiry
-
setExpiryMillis
public void setExpiryMillis(long lMillis)
Specify when the cache entry will expire, or disable expiry. Note that if the cache is configured for automatic expiry, each subsequent update to this cache entry will reschedule the expiry time.- Specified by:
setExpiryMillisin interfaceConfigurableCacheMap.Entry- Parameters:
lMillis- pass the date/time value, in millis, for when the entry will expire, or pass zero to disable automatic expiry
-
registerExpiry
protected void registerExpiry(long lMillis)
Register (or unregister or replace the registration of) this entry for expiry.- Parameters:
lMillis- the date/time value for when the entry will expire; 0 is passed to indicate that the entry needs to be removed from the items queued for expiry
-
isExpired
public boolean isExpired()
Determine if the cache entry has expired.- Returns:
- true if the cache entry was subject to automatic expiry and the current time is greater than the entry's expiry time
-
scheduleExpiry
protected void scheduleExpiry()
Reschedule the cache entry expiration.
-
discard
protected void discard()
Called to inform the Entry that it is no longer used.
-
isDiscarded
protected boolean isDiscarded()
Determine if this entry has already been discarded from the cache.- Returns:
- true if this entry has been discarded
-
calculateUnits
protected int calculateUnits(Object oValue)
Calculate a cache cost for the specified object.The default implementation uses the unit calculator type of the containing cache.
- Parameters:
oValue- the cache value to evaluate for unit cost- Returns:
- an integer value 0 or greater, with a larger value signifying a higher cost
-
getUnits
public int getUnits()
Determine the number of cache units used by this Entry.- Specified by:
getUnitsin interfaceConfigurableCacheMap.Entry- Returns:
- an integer value 0 or greater, with a larger value signifying a higher cost; -1 implies that the Entry has been discarded
-
setUnits
public void setUnits(int cUnits)
Specify the number of cache units used by this Entry.- Specified by:
setUnitsin interfaceConfigurableCacheMap.Entry- Parameters:
cUnits- an integer value 0 or greater, with a larger value signifying a higher cost
-
isEvictable
protected boolean isEvictable()
Determine if this entry has been marked as being evictable.- Returns:
- true if this entry is evictable
- Since:
- Coherence 3.5
-
setEvictable
protected void setEvictable(boolean fEvict)
Specify that this entry is evictable or not.- Parameters:
fEvict- true to specify that this entry is evictable, such as when it is selected for deferred eviction, and false to specify that it is no longer evictable- Since:
- Coherence 3.5
-
toString
public String toString()
Render the cache entry as a String.- Overrides:
toStringin classSafeHashMap.Entry- Returns:
- the details about this Entry
-
-