org.ehcache.expiry
Interface Expiry<K,V>

Type Parameters:
K - the type of the keys used to access data within the cache
V - the type of the values held within the cache

public interface Expiry<K,V>

A policy object that governs expiration for a Cache

See Expirations for common instances


Method Summary
 Duration getExpiryForAccess(K key, V value)
          Get the expiration period (relative to the current time) when an existing entry is accessed from a Cache
 Duration getExpiryForCreation(K key, V value)
          Get the expiration period (relative to the current time) when a entry is initially added to a Cache
 Duration getExpiryForUpdate(K key, V oldValue, V newValue)
          Get the expiration period (relative to the current time) when an existing entry is updated in a Cache NOTE: Some cache configurations (eg.
 

Method Detail

getExpiryForCreation

Duration getExpiryForCreation(K key,
                              V value)
Get the expiration period (relative to the current time) when a entry is initially added to a Cache

Parameters:
key - the key of the newly added entry
value - the value of the newly added entry
Returns:
a non-null Duration

getExpiryForAccess

Duration getExpiryForAccess(K key,
                            V value)
Get the expiration period (relative to the current time) when an existing entry is accessed from a Cache

Parameters:
key - the key of the accessed entry
value - the value of the accessed entry
Returns:
the updated expiration value for the given entry. A null return value indicates "no change" to the expiration time

getExpiryForUpdate

Duration getExpiryForUpdate(K key,
                            V oldValue,
                            V newValue)
Get the expiration period (relative to the current time) when an existing entry is updated in a Cache NOTE: Some cache configurations (eg. caches with eventual consistency) may use local (ie. non-consistent) state to decide whether to call getExpiryForUpdate() vs. getExpiryForCreation(). For these cache configurations it is advised to return the same value from both of these methods

Parameters:
key - the key of the updated entry
oldValue - the previous value of the entry
newValue - the new value of the entry
Returns:
the updated expiration value for the given entry. A null return value indicates "no change" to the expiration time