V - The value typepublic final class AccessTimeObjectHolder<V> extends Object implements TCacheHolder<V>
| Constructor and Description |
|---|
AccessTimeObjectHolder(V value,
CacheWriteMode writeMode)
Construct a holder.
|
AccessTimeObjectHolder(V value,
long maxIdleTimeMillis,
long maxCacheTimeSecs,
CacheWriteMode writeMode) |
| Modifier and Type | Method and Description |
|---|---|
V |
get()
Returns the value, that this holder holds.
|
long |
getCreationTime()
Returns the creation time of this holder, given in ms since EPOCH.
|
long |
getExpirationTime()
Returns the expiration time, given in ms since EPOCH.
|
long |
getLastAccessTime()
Returns the last access time, given in MILLISECONDS since EPOCH
|
int |
getUseCount()
Returns the number of times this holder was accessed.
|
void |
incrementUseCount() |
boolean |
isInvalid()
Returns whether this holder is valid.
|
static boolean |
isValid(AccessTimeObjectHolder<?> holder)
Returns whether the holder is valid.
|
V |
peek()
Returns the value, that this holder holds.
|
protected boolean |
release()
Releases all references to objects that this holder holds.
|
void |
setExpireUntil(int maxDelay,
TimeUnit timeUnit,
Random random)
|-------------- maxCacheTimeMillis --------------|
| |
|--- newMaxCacheTimeMillis ---| |
| | |
-|---------|-------------------|------------------|------------------------------------- time
| | | |
| now now + delayMillis |
| = expirationOnNewExpireUntil |
| |
inputDate + baseTimeMillis = creationTime creationTime + maxCacheTime
|
void |
setMaxIdleTime(int idleTime,
TimeUnit timeUnit) |
String |
toString() |
void |
updateMaxIdleTime(long idleTimeMillis)
Prolongs the maxIdleTime by the given idleTime. 0 means immediate expiration, -1 means to not change anything, any positive value is the prolongation in seconds.
|
public AccessTimeObjectHolder(V value, CacheWriteMode writeMode) throws javax.cache.CacheException
complete(long, long)value - The value to store in this holderwriteMode - The CacheWriteMode that defines how to serialize the datajavax.cache.CacheException - when there is a problem serializing the valuepublic AccessTimeObjectHolder(V value, long maxIdleTimeMillis, long maxCacheTimeSecs, CacheWriteMode writeMode) throws javax.cache.CacheException
javax.cache.CacheExceptionpublic static boolean isValid(AccessTimeObjectHolder<?> holder)
holder - The holder to checkprotected boolean release()
This is the end-of-life for the instance, and isInvalid() yields true from now on. If a reference to this holder is stored for a longer
time, a Thread should check isInvalid().
public void setMaxIdleTime(int idleTime,
TimeUnit timeUnit)
public void updateMaxIdleTime(long idleTimeMillis)
idleTimeMillis - The time for prolong in milliseconds. See description for the special values 0 and -1.public long getExpirationTime()
TCacheHoldergetExpirationTime in interface TCacheHolder<V>public V get()
TODO The use count is not yet updated here. This makes behavior inconsistent, e.g. in the iterator
get in interface TCacheHolder<V>public V peek()
TCacheHolderTCacheHolder.get() in that peek has no side effects on entry statistics.peek in interface TCacheHolder<V>public long getLastAccessTime()
TCacheHoldergetLastAccessTime in interface TCacheHolder<V>public int getUseCount()
TCacheHoldergetUseCount in interface TCacheHolder<V>public void incrementUseCount()
public long getCreationTime()
TCacheHoldergetCreationTime in interface TCacheHolder<V>public boolean isInvalid()
TCacheHolderisInvalid in interface TCacheHolder<V>public void setExpireUntil(int maxDelay,
TimeUnit timeUnit,
Random random)
|-------------- maxCacheTimeMillis --------------| | | |--- newMaxCacheTimeMillis ---| | | | | -|---------|-------------------|------------------|------------------------------------- time | | | | | now now + delayMillis | | = expirationOnNewExpireUntil | | | inputDate + baseTimeMillis = creationTime creationTime + maxCacheTime
maxDelay - The maximum delay time until the object will be expiredtimeUnit - The time unit for maxDelayrandom - The random generator to useCopyright © 2018 trivago. All rights reserved.