|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
K
- the key type for the cacheV
- the value type for the cachepublic interface Expiry<K,V>
A policy object that governs expiration for mappings in a Cache
.
Previous values are not accessible directly but are rather available through a value supplier
to indicate that access can require computation (such as deserialization).
NOTE: Some cache configurations (eg. caches with eventual consistency) may use local (ie. non-consistent) state
to decide whether to call getExpiryForUpdate(Object, ValueSupplier, Object)
vs.
getExpiryForCreation(Object, Object)
. For these cache configurations it is advised to return the same
value for both of these methods
See Expirations
for helper methods to create common Expiry
instances.
Expirations
Method Summary | |
---|---|
Duration |
getExpiryForAccess(K key,
ValueSupplier<? extends V> value)
Returns the expiration Duration (relative to the current time) when an existing entry is accessed from a
Cache . |
Duration |
getExpiryForCreation(K key,
V value)
Returns the lifetime of an entry when it is initially added to a Cache . |
Duration |
getExpiryForUpdate(K key,
ValueSupplier<? extends V> oldValue,
V newValue)
Returns the expiration Duration (relative to the current time) when an existing entry is updated in a
Cache . |
Method Detail |
---|
Duration getExpiryForCreation(K key, V value)
Cache
.
This method must not return null
.
Exceptions thrown from this method will be swallowed and result in the expiry duration being
ZERO
.
key
- the key of the newly added entryvalue
- the value of the newly added entry
Duration
Duration getExpiryForAccess(K key, ValueSupplier<? extends V> value)
Duration
(relative to the current time) when an existing entry is accessed from a
Cache
.
Returning null
indicates that the expiration time remains unchanged.
Exceptions thrown from this method will be swallowed and result in the expiry duration being
ZERO
.
key
- the key of the accessed entryvalue
- a value supplier for the accessed entry
Duration
, null
means unchangedDuration getExpiryForUpdate(K key, ValueSupplier<? extends V> oldValue, V newValue)
Duration
(relative to the current time) when an existing entry is updated in a
Cache
.
Returning null
indicates that the expiration time remains unchanged.
Exceptions thrown from this method will be swallowed and result in the expiry duration being
ZERO
.
key
- the key of the updated entryoldValue
- a value supplier for the previous value of the entrynewValue
- the new value of the entry
Duration
, null
means unchanged
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |