org.terracotta.cache.serialization
Class CustomLifespanSerializedEntry<T>

java.lang.Object
  extended by org.terracotta.cache.value.AbstractStatelessTimestampedValue<V>
      extended by org.terracotta.cache.value.AbstractTimestampedValue<byte[]>
          extended by org.terracotta.cache.serialization.SerializedEntry<T>
              extended by org.terracotta.cache.serialization.CustomLifespanSerializedEntry<T>
All Implemented Interfaces:
Externalizable, Serializable, ExpirableEntry, MarkTimestampedValue, TimestampedValue<byte[]>

public class CustomLifespanSerializedEntry<T>
extends SerializedEntry<T>

A SerializedEntry subclass that supports cache entries with custom TTI/TTL values.

Author:
Chris Dennis
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.terracotta.cache.value.AbstractTimestampedValue
lastAccessedTime
 
Fields inherited from class org.terracotta.cache.value.AbstractStatelessTimestampedValue
UNUSED
 
Fields inherited from interface org.terracotta.cache.TimestampedValue
NEVER_EXPIRE
 
Constructor Summary
CustomLifespanSerializedEntry()
           
CustomLifespanSerializedEntry(SerializedEntryParameters<T> params, int tti, int ttl)
           
CustomLifespanSerializedEntry(T deserialized, byte[] serialized, int tti, int ttl, int createTime)
          Constructs a serialized entry with a custom lifespan and creation time.
CustomLifespanSerializedEntry(T deserialized, byte[] serialized, int tti, int ttl, int createTime, int lastAccessedTime)
          Constructs a serialized entry with a custom lifespan, creation time, and last accessed time.
CustomLifespanSerializedEntry(T deserialized, byte[] serialized, int tti, int ttl, TimeSource timeSource)
          Constructs a serialized entry with a custom lifespan and creation time.
 
Method Summary
 int expiresAt(CacheConfig config)
          Get the time at which this timestamp will become invalid.
 void readExternal(ObjectInput in)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.terracotta.cache.serialization.SerializedEntry
addedToLocalCache, equals, getCreateTime, getDeserializedValue, getDeserializedValue, getDeserializedValueCopy, getDeserializedValueCopy, getValue, markTxnComplete, markTxnInProgress, nullByteArray, shouldRecalculateSize, toString, unsafelyGetDeserializedValue, unsafelyGetDeserializedValueCopy
 
Methods inherited from class org.terracotta.cache.value.AbstractTimestampedValue
fastGetCapacityEvictionPolicyData, getCapacityEvictionPolicyData, getLastAccessedTime, setCapacityEvictionPolicyData, setLastAccessedTimeInternal
 
Methods inherited from class org.terracotta.cache.value.AbstractStatelessTimestampedValue
expiresAt, hashCode, isExpired, markUsed, markUsed
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CustomLifespanSerializedEntry

public CustomLifespanSerializedEntry()

CustomLifespanSerializedEntry

public CustomLifespanSerializedEntry(T deserialized,
                                     byte[] serialized,
                                     int tti,
                                     int ttl,
                                     TimeSource timeSource)
Constructs a serialized entry with a custom lifespan and creation time.

The constructed entry will have it's creation and last accessed time set to be the same, as would be normal for a newly constructed entry.

Parameters:
deserialized - non-serialized entry value
serialized - serialized entry value
tti - custom time-to-idle
ttl - custom time-to-live
timeSource - source for timestamps

CustomLifespanSerializedEntry

public CustomLifespanSerializedEntry(T deserialized,
                                     byte[] serialized,
                                     int tti,
                                     int ttl,
                                     int createTime)
Constructs a serialized entry with a custom lifespan and creation time.

The constructed entry will have it's creation and last accessed time set to be the same, as would be normal for a newly constructed entry.

Parameters:
deserialized - non-serialized entry value
serialized - serialized entry value
tti - custom time-to-idle
ttl - custom time-to-live
createTime - creation/last accessed time

CustomLifespanSerializedEntry

public CustomLifespanSerializedEntry(T deserialized,
                                     byte[] serialized,
                                     int tti,
                                     int ttl,
                                     int createTime,
                                     int lastAccessedTime)
Constructs a serialized entry with a custom lifespan, creation time, and last accessed time.

Parameters:
deserialized - non-serialized entry value
serialized - serialized entry value
tti - custom time-to-idle
ttl - custom time-to-live
createTime - creation time
lastAccessedTime - last accessed time

CustomLifespanSerializedEntry

public CustomLifespanSerializedEntry(SerializedEntryParameters<T> params,
                                     int tti,
                                     int ttl)
Method Detail

expiresAt

public int expiresAt(CacheConfig config)
Description copied from class: AbstractStatelessTimestampedValue
Get the time at which this timestamp will become invalid. If the config specified ttl == tti == 0, making items eternal, then this method returns TimestampedValue.NEVER_EXPIRE.

Specified by:
expiresAt in interface TimestampedValue<byte[]>
Overrides:
expiresAt in class AbstractStatelessTimestampedValue<byte[]>
Parameters:
config - The configuration
Returns:
Timestamp of expiration, >0, may be NEVER_EXPIRE if eternal

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class SerializedEntry<T>
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class SerializedEntry<T>
Throws:
IOException


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