Class LocalCacheValue
- java.lang.Object
-
- com.tangosol.coherence.jcache.localcache.LocalCacheValue
-
public class LocalCacheValue extends Object
Represents the internal Cache Entry Value with in anLocalCache.The actual value passed to the Cache is represented in an internal format, generated by passing the value through an
InternalConverter.LocalCacheValues additionally store and provide meta information about Cache Entry Values, including information for dealing with expiry.- Since:
- Coherence 12.1.3
- Author:
- bo 2013.12.19
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLocalCacheValue.JCacheSyntheticKindSynthetic Update
-
Constructor Summary
Constructors Constructor Description LocalCacheValue(LocalCacheValue oldValue)Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccessInternalValue(long ldtAccess, javax.cache.expiry.ExpiryPolicy policy)Access valuestatic LocalCacheValuecreateLoadedLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)Create a LocalCacheValue marked with Synthetic marker that it was loaded.static LocalCacheValuecreateLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)Create a LocalCacheValue for an LocalCache entry.Objectget()Gets the internal value (without updating the access time).longgetAccessCount()Gets the number of times the internal value has been accessed.longgetAccessTime()Gets the time (since the Epoc) in milliseconds since the internal value was last accessed.longgetCreationTime()Gets the time (since the Epoc) in milliseconds since the internal value was created.longgetExpiryTime()Gets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.ObjectgetInternalValue()Access internal value without updating access expiry.ObjectgetInternalValue(long ldtAccess)Gets the internal value with the side-effect of updating the access time to that which is specified and incrementing the access count.longgetModificationCount()Gets the number of times the internal value has been modified (set)longgetModificationTime()Gets the time (since the Epoc) in milliseconds since the internal value was last modified.booleanisExpiredAt(long ldtNow)Determines if the Cache Entry associated with this value would be expired at the specified timebooleanisLoaded()Determine if last update to this LocalValue was a load from an external resource.booleanisSyntheticUpdate()determine if last update was considered syntheticvoidset(Object internalValue)Sets the internal value (without updating the modification time)voidsetExpiryTime(long ldtExpiry)Sets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.LocalCacheValueupdateInternalValue(Object internalValue, long ldtModification, javax.cache.expiry.ExpiryPolicy policy)Sets the internal value with the additional side-effect of updating the modification time to that which is specified and incrementing the modification count.
-
-
-
Constructor Detail
-
LocalCacheValue
public LocalCacheValue(LocalCacheValue oldValue)
Copy constructor- Parameters:
oldValue- the old local cache value
-
-
Method Detail
-
getCreationTime
public long getCreationTime()
Gets the time (since the Epoc) in milliseconds since the internal value was created.- Returns:
- time in milliseconds (since the Epoc)
-
getAccessTime
public long getAccessTime()
Gets the time (since the Epoc) in milliseconds since the internal value was last accessed.- Returns:
- time in milliseconds (since the Epoc)
-
getAccessCount
public long getAccessCount()
Gets the number of times the internal value has been accessed.- Returns:
- the access count
-
getModificationTime
public long getModificationTime()
Gets the time (since the Epoc) in milliseconds since the internal value was last modified.- Returns:
- time in milliseconds (since the Epoc)
-
getModificationCount
public long getModificationCount()
Gets the number of times the internal value has been modified (set)- Returns:
- the modification count
-
getExpiryTime
public long getExpiryTime()
Gets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.- Returns:
- time in milliseconds (since the Epoc)
-
setExpiryTime
public void setExpiryTime(long ldtExpiry)
Sets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.- Parameters:
ldtExpiry- time in milliseconds (since the Epoc)
-
isExpiredAt
public boolean isExpiredAt(long ldtNow)
Determines if the Cache Entry associated with this value would be expired at the specified time- Parameters:
ldtNow- time in milliseconds (since the Epoc)- Returns:
- true if the value would be expired at the specified time
-
get
public Object get()
Gets the internal value (without updating the access time).- Returns:
- the internal value
-
set
public void set(Object internalValue)
Sets the internal value (without updating the modification time)- Parameters:
internalValue- the new internal value
-
getInternalValue
public Object getInternalValue(long ldtAccess)
Gets the internal value with the side-effect of updating the access time to that which is specified and incrementing the access count.- Parameters:
ldtAccess- the time when the internal value was accessed- Returns:
- the internal value
-
getInternalValue
public Object getInternalValue()
Access internal value without updating access expiry. Added this method for accessing value to construct a CacheEntryEvent. This access should not be considered for resetting expiry for an access. With StoreByReference configured to true, this access for CacheEntryEvent could end up modifying the LocalCachedValue in the LocalCache.- Returns:
- internal value
-
updateInternalValue
public LocalCacheValue updateInternalValue(Object internalValue, long ldtModification, javax.cache.expiry.ExpiryPolicy policy)
Sets the internal value with the additional side-effect of updating the modification time to that which is specified and incrementing the modification count.- Parameters:
internalValue- the new internal valueldtModification- the time when the value was modifiedpolicy- the expiry policy- Returns:
- this LocalCacheValue
-
accessInternalValue
public void accessInternalValue(long ldtAccess, javax.cache.expiry.ExpiryPolicy policy)Access value- Parameters:
ldtAccess- the time when the value was accessedpolicy- the expiry policy
-
createLoadedLocalCacheValue
public static LocalCacheValue createLoadedLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)
Create a LocalCacheValue marked with Synthetic marker that it was loaded. This distinction is necessary to ensure that a just read-through entry from an external resource is not immediately written back to external resource via write-through.- Parameters:
internalValue- internal format of value of a LocalCache entryldtCreation- creation timepolicy- expiry policy to use- Returns:
- a
LocalCacheValuemarked as loaded via read-through
-
createLocalCacheValue
public static LocalCacheValue createLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)
Create a LocalCacheValue for an LocalCache entry.- Parameters:
internalValue- internal format of valueldtCreation- entry creation timepolicy- expiry policy to use to generate expiry for the new LocalCache entry.- Returns:
LocalCachewith appropriate JCache MetaInfo.
-
isSyntheticUpdate
public boolean isSyntheticUpdate()
determine if last update was considered synthetic- Returns:
- synthetic update state
-
isLoaded
public boolean isLoaded()
Determine if last update to this LocalValue was a load from an external resource.- Returns:
- true iff this value has not been updated since it was last loaded.
-
-