Package org.infinispan.container.entries
Class TransientCacheEntry
- java.lang.Object
-
- org.infinispan.container.entries.AbstractInternalCacheEntry
-
- org.infinispan.container.entries.TransientCacheEntry
-
- All Implemented Interfaces:
Cloneable
,Map.Entry
,CacheEntry
,InternalCacheEntry
,MetadataAware
public class TransientCacheEntry extends AbstractInternalCacheEntry
A cache entry that is transient, i.e., it can be considered expired after a period of not being used.- Since:
- 4.0
- Author:
- Manik Surtani
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TransientCacheEntry.Externalizer
-
Constructor Summary
Constructors Constructor Description TransientCacheEntry(Object key, Object value, long maxIdle, long lastUsed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canExpire()
boolean
canExpireMaxIdle()
TransientCacheEntry
clone()
long
getCreated()
long
getExpiryTime()
Only used with entries that have a lifespan, this determines when an entry is due to expire.long
getLastUsed()
long
getLifespan()
long
getMaxIdle()
Metadata
getMetadata()
Get metadata of this cache entry.Object
getValue()
Retrieves the value of this entryboolean
isExpired()
boolean
isExpired(long now)
void
reincarnate()
"Reincarnates" an entry.void
reincarnate(long now)
"Reincarnates" an entry.void
setMaxIdle(long maxIdle)
void
setMetadata(Metadata metadata)
Set the metadata in the cache entry.Object
setValue(Object value)
Sets the value of the entry, returning the previous valueInternalCacheValue
toInternalCacheValue()
Creates a representation of this entry as anInternalCacheValue
.String
toString()
void
touch()
Updates access timestamps on this instancevoid
touch(long currentTimeMillis)
Updates access timestamps on this instance to a specified time-
Methods inherited from class org.infinispan.container.entries.AbstractInternalCacheEntry
commit, equals, getKey, hashCode, isChanged, isCreated, isEvicted, isL1Entry, isNull, isRemoved, setChanged, setCreated, setEvicted, setRemoved, setSkipLookup, skipLookup
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.infinispan.container.entries.CacheEntry
commit, isLoaded, isValid, rollback, setCreated, setLastUsed, setLoaded, setValid, undelete
-
-
-
-
Field Detail
-
value
protected Object value
-
maxIdle
protected long maxIdle
-
lastUsed
protected long lastUsed
-
-
Method Detail
-
getValue
public Object getValue()
Description copied from interface:CacheEntry
Retrieves the value of this entry- Returns:
- the value of the entry
-
setValue
public Object setValue(Object value)
Description copied from interface:CacheEntry
Sets the value of the entry, returning the previous value- Parameters:
value
- value to set- Returns:
- previous value
-
touch
public final void touch()
Description copied from interface:InternalCacheEntry
Updates access timestamps on this instance
-
touch
public final void touch(long currentTimeMillis)
Description copied from interface:InternalCacheEntry
Updates access timestamps on this instance to a specified time- Parameters:
currentTimeMillis
- the current time as defined bySystem.currentTimeMillis()
orTimeService.wallClockTime()
-
reincarnate
public final void reincarnate()
Description copied from interface:InternalCacheEntry
"Reincarnates" an entry. Essentially, resets the 'created' timestamp of the entry to the current time.
-
reincarnate
public void reincarnate(long now)
Description copied from interface:InternalCacheEntry
"Reincarnates" an entry. Essentially, resets the 'created' timestamp of the entry to the current time.- Parameters:
now
- the current time as defined bySystem.currentTimeMillis()
orTimeService.wallClockTime()
-
canExpire
public final boolean canExpire()
- Returns:
- true if the entry can expire, false otherwise
-
canExpireMaxIdle
public boolean canExpireMaxIdle()
- Returns:
- true if this entry can expire via max idle, false otherwise
-
isExpired
public boolean isExpired(long now)
- Parameters:
now
- the current time as defined bySystem.currentTimeMillis()
orTimeService.wallClockTime()
- Returns:
- true if the entry has expired; false otherwise
-
isExpired
public boolean isExpired()
- Returns:
- true if the entry has expired; false otherwise
-
setMaxIdle
public void setMaxIdle(long maxIdle)
-
getCreated
public long getCreated()
- Returns:
- timestamp when the entry was created
-
getLastUsed
public final long getLastUsed()
- Returns:
- timestamp when the entry was last used
-
getLifespan
public long getLifespan()
- Returns:
- retrieves the lifespan of this entry. -1 means an unlimited lifespan.
-
getExpiryTime
public long getExpiryTime()
Description copied from interface:InternalCacheEntry
Only used with entries that have a lifespan, this determines when an entry is due to expire.- Returns:
- timestamp when the entry is due to expire, or -1 if it doesn't have a lifespan
-
getMaxIdle
public final long getMaxIdle()
- Returns:
- the maximum allowed time for which this entry can be idle, after which it is considered expired.
-
toInternalCacheValue
public InternalCacheValue toInternalCacheValue()
Description copied from interface:InternalCacheEntry
Creates a representation of this entry as anInternalCacheValue
. The main purpose of this is to provide a representation that does not have a reference to the key. This is useful in situations where the key is already known or stored elsewhere, making serialization and deserialization more efficient. Note that this should not be used to optimize memory overhead, since the saving of an additional reference to a key (a single object reference) does not warrant the cost of constructing an InternalCacheValue. This only makes sense when marshalling is involved, since the cost of marshalling the key again can be sidestepped using an InternalCacheValue if the key is already known/marshalled.- Returns:
- a new InternalCacheValue encapsulating this InternalCacheEntry's value and expiration information.
-
getMetadata
public Metadata getMetadata()
Description copied from interface:MetadataAware
Get metadata of this cache entry.- Specified by:
getMetadata
in interfaceMetadataAware
- Overrides:
getMetadata
in classAbstractInternalCacheEntry
- Returns:
- a Metadata instance
-
setMetadata
public void setMetadata(Metadata metadata)
Description copied from interface:MetadataAware
Set the metadata in the cache entry.- Specified by:
setMetadata
in interfaceMetadataAware
- Overrides:
setMetadata
in classAbstractInternalCacheEntry
- Parameters:
metadata
- to apply to the cache entry
-
clone
public TransientCacheEntry clone()
- Specified by:
clone
in interfaceCacheEntry
- Specified by:
clone
in interfaceInternalCacheEntry
- Overrides:
clone
in classAbstractInternalCacheEntry
-
toString
public String toString()
- Overrides:
toString
in classAbstractInternalCacheEntry
-
-