org.terracotta.cache
Interface TimestampedValue<V>

All Superinterfaces:
ExpirableEntry
All Known Implementing Classes:
AbstractStatelessTimestampedValue, AbstractTimestampedValue, CustomLifespanSerializedEntry, DefaultTimestampedValue, SerializedEntry

public interface TimestampedValue<V>
extends ExpirableEntry

Inside a DistributedCache, the map values are wrapped in a TimestampedValue that combines the actual value with information on created and last accessed times.


Field Summary
static int NEVER_EXPIRE
          Indicates the value will never expire (Integer.MAX_VALUE).
 
Method Summary
 int expiresAt(CacheConfig config)
          Determine when this value will expire based on the current configuration.
 CapacityEvictionPolicyData getCapacityEvictionPolicyData()
          Retrieves this value's capacity eviction policy data.
 int getCreateTime()
          Retrieves the time when this value was created.
 int getLastAccessedTime()
          Retrieves the time when this value was last accessed.
 V getValue()
          Get the actual value in the cache.
 boolean isExpired(int time, CacheConfig config)
          Determine whether this value will be expired at time based on the config.
 void markUsed(int usedAt, ClusteredLock lock, CacheConfig config)
          Mark this value as being used at the specified time.
 void setCapacityEvictionPolicyData(CapacityEvictionPolicyData capacityEvictionPolicyData)
          Sets this value's capacity eviction policy data.
 
Methods inherited from interface org.terracotta.cache.ExpirableEntry
expiresAt
 

Field Detail

NEVER_EXPIRE

static final int NEVER_EXPIRE
Indicates the value will never expire (Integer.MAX_VALUE).

See Also:
Constant Field Values
Method Detail

expiresAt

int expiresAt(CacheConfig config)
Determine when this value will expire based on the current configuration.

Parameters:
config - The configuration
Returns:
The timestamp (in seconds since the epoch) when this value will expire. May return NEVER_EXPIRE if it will never expire.

isExpired

boolean isExpired(int time,
                  CacheConfig config)
Determine whether this value will be expired at time based on the config.

Parameters:
time - The time in seconds since the epoch for which to check. Should be > 0.
config - The cache configuration
Returns:
True if expired

getValue

V getValue()
Get the actual value in the cache.

Returns:
The value

markUsed

void markUsed(int usedAt,
              ClusteredLock lock,
              CacheConfig config)
Mark this value as being used at the specified time. This updates the value's last accessed time.

Parameters:
usedAt - Current time in seconds since the epoch
lock - The lock guarding this value, such as would be obtained by calling the underlying ConcurrentDistributedMap.createFinegrainedLock() method
config - The cache configuration

getCreateTime

int getCreateTime()
Retrieves the time when this value was created.

Returns:
this value's creation time in seconds since epoch

getLastAccessedTime

int getLastAccessedTime()
Retrieves the time when this value was last accessed.

Returns:
this value's last access time in seconds since epoch

setCapacityEvictionPolicyData

void setCapacityEvictionPolicyData(CapacityEvictionPolicyData capacityEvictionPolicyData)
Sets this value's capacity eviction policy data.

Parameters:
capacityEvictionPolicyData - the new data

getCapacityEvictionPolicyData

CapacityEvictionPolicyData getCapacityEvictionPolicyData()
Retrieves this value's capacity eviction policy data.

Returns:
this value's data


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.