K
- the type of the keys used to access data within the cacheV
- the type of the values held within the cachepublic interface Expiry<K,V>
Cache
.
Previous values are not accessible directly but are rather available through a value supplier
to indicate that access can be require computation such as deserialization.
See Expirations
for common instances.
Modifier and Type | Method and Description |
---|---|
Duration |
getExpiryForAccess(K key,
ValueSupplier<? extends 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,
ValueSupplier<? extends 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. |
Duration getExpiryForCreation(K key, V value)
Cache
key
- the key of the newly added entryvalue
- the value of the newly added entryDuration
Duration getExpiryForAccess(K key, ValueSupplier<? extends V> value)
Cache
key
- the key of the accessed entryvalue
- a value supplier for the accessed entrynull
return value indicates "no change" to the expiration timeDuration getExpiryForUpdate(K key, ValueSupplier<? extends V> oldValue, V newValue)
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 methodskey
- the key of the updated entryoldValue
- a value supplier for the previous value of the entrynewValue
- the new value of the entrynull
return value indicates "no change" to the expiration time