Class Async.AsyncExpiry<K,V>
java.lang.Object
com.github.benmanes.caffeine.cache.Async.AsyncExpiry<K,V>
- All Implemented Interfaces:
Expiry<K, CompletableFuture<V>>, Serializable
- Enclosing class:
Async
static final class Async.AsyncExpiry<K,V>
extends Object
implements Expiry<K, CompletableFuture<V>>, Serializable
An expiry for asynchronous computations. When the value is being loaded this expiry returns
ASYNC_EXPIRY to indicate that the entry should not be evicted due to an expiry
constraint. If the value is computed successfully the entry must be reinserted so that the
expiration is updated and the expiration timeouts reflect the value once present. The value
maximum range is reserved to coordinate the asynchronous life cycle.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongexpireAfterCreate(K key, CompletableFuture<V> future, long currentTime) Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation.longexpireAfterRead(K key, CompletableFuture<V> future, long currentTime, long currentDuration) Specifies that the entry should be automatically removed from the cache once the duration has elapsed after its last read.longexpireAfterUpdate(K key, CompletableFuture<V> future, long currentTime, long currentDuration) Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the replacement of its value.(package private) Object
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
delegate
-
-
Constructor Details
-
AsyncExpiry
-
-
Method Details
-
expireAfterCreate
Description copied from interface:ExpirySpecifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation. To indicate no expiration an entry may be given an excessively long period, such asLong#MAX_VALUE.Note: The
currentTimeis supplied by the configuredTickerand by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.- Specified by:
expireAfterCreatein interfaceExpiry<K,V> - Parameters:
key- the key represented by this entryfuture- the value represented by this entrycurrentTime- the current time, in nanoseconds- Returns:
- the length of time before the entry expires, in nanoseconds
-
expireAfterUpdate
public long expireAfterUpdate(K key, CompletableFuture<V> future, long currentTime, long currentDuration) Description copied from interface:ExpirySpecifies that the entry should be automatically removed from the cache once the duration has elapsed after the replacement of its value. To indicate no expiration an entry may be given an excessively long period, such asLong#MAX_VALUE. ThecurrentDurationmay be returned to not modify the expiration time.Note: The
currentTimeis supplied by the configuredTickerand by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.- Specified by:
expireAfterUpdatein interfaceExpiry<K,V> - Parameters:
key- the key represented by this entryfuture- the value represented by this entrycurrentTime- the current time, in nanosecondscurrentDuration- the current duration, in nanoseconds- Returns:
- the length of time before the entry expires, in nanoseconds
-
expireAfterRead
public long expireAfterRead(K key, CompletableFuture<V> future, long currentTime, long currentDuration) Description copied from interface:ExpirySpecifies that the entry should be automatically removed from the cache once the duration has elapsed after its last read. To indicate no expiration an entry may be given an excessively long period, such asLong#MAX_VALUE. ThecurrentDurationmay be returned to not modify the expiration time.Note: The
currentTimeis supplied by the configuredTickerand by default does not relate to system or wall-clock time. When calculating the duration based on a time stamp, the current time should be obtained independently.- Specified by:
expireAfterReadin interfaceExpiry<K,V> - Parameters:
key- the key represented by this entryfuture- the value represented by this entrycurrentTime- the current time, in nanosecondscurrentDuration- the current duration, in nanoseconds- Returns:
- the length of time before the entry expires, in nanoseconds
-
writeReplace
Object writeReplace()
-