Class LocalCacheValue

java.lang.Object
com.tangosol.coherence.jcache.localcache.LocalCacheValue

public class LocalCacheValue extends Object
Represents the internal Cache Entry Value with in an LocalCache.

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 enum 
    Synthetic Update
  • Constructor Summary

    Constructors
    Constructor
    Description
    Copy constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accessInternalValue(long ldtAccess, javax.cache.expiry.ExpiryPolicy policy)
    Access value
    createLoadedLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)
    Create a LocalCacheValue marked with Synthetic marker that it was loaded.
    createLocalCacheValue(Object internalValue, long ldtCreation, javax.cache.expiry.ExpiryPolicy policy)
    Create a LocalCacheValue for an LocalCache entry.
    get()
    Gets the internal value (without updating the access time).
    long
    Gets the number of times the internal value has been accessed.
    long
    Gets the time (since the Epoc) in milliseconds since the internal value was last accessed.
    long
    Gets the time (since the Epoc) in milliseconds since the internal value was created.
    long
    Gets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.
    Access internal value without updating access expiry.
    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.
    long
    Gets the number of times the internal value has been modified (set)
    long
    Gets the time (since the Epoc) in milliseconds since the internal value was last modified.
    boolean
    isExpiredAt(long ldtNow)
    Determines if the Cache Entry associated with this value would be expired at the specified time
    boolean
    Determine if last update to this LocalValue was a load from an external resource.
    boolean
    determine if last update was considered synthetic
    void
    set(Object internalValue)
    Sets the internal value (without updating the modification time)
    void
    setExpiryTime(long ldtExpiry)
    Sets the time (since the Epoc) in milliseconds when the Cache Entry associated with this value should be considered expired.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LocalCacheValue

      public LocalCacheValue(LocalCacheValue oldValue)
      Copy constructor
      Parameters:
      oldValue - the old local cache value
  • Method Details

    • 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 value
      ldtModification - the time when the value was modified
      policy - 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 accessed
      policy - 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 entry
      ldtCreation - creation time
      policy - expiry policy to use
      Returns:
      a LocalCacheValue marked 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 value
      ldtCreation - entry creation time
      policy - expiry policy to use to generate expiry for the new LocalCache entry.
      Returns:
      LocalCache with 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.