Top Description Methods
com.github.benmanes.caffeine.cache

public Interface Expiry<K, V>

Known Direct Implementers
com.github.benmanes.caffeine.cache.Async.AsyncExpiry, com.github.benmanes.caffeine.cache.BoundedLocalCache.BoundedPolicy.FixedExpireAfterWrite
Imports
org.checkerframework.checker.index.qual.NonNegative

Calculates when cache entries expire. A single expiration time is retained so that the lifetime of an entry may be extended or reduced by subsequent evaluations.
Author
[email protected] (Ben Manes)

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the length of time before the entry expires, in nanoseconds
expireAfterCreate
(K
the key represented by this entry
key
,
V
the value represented by this entry
value
,
long
the current time, in nanoseconds
currentTime
)

Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the entry's creation.

public long

Returns:

the length of time before the entry expires, in nanoseconds
expireAfterRead
(K
the key represented by this entry
key
,
V
the value represented by this entry
value
,
long
the current time, in nanoseconds
currentTime
,
@NonNegative long
the current duration, in nanoseconds
currentDuration
)

Specifies that the entry should be automatically removed from the cache once the duration has elapsed after its last read.

public long

Returns:

the length of time before the entry expires, in nanoseconds
expireAfterUpdate
(K
the key represented by this entry
key
,
V
the value represented by this entry
value
,
long
the current time, in nanoseconds
currentTime
,
@NonNegative long
the current duration, in nanoseconds
currentDuration
)

Specifies that the entry should be automatically removed from the cache once the duration has elapsed after the replacement of its value.

Method Detail

expireAfterCreateback to summary
public long expireAfterCreate(K key, V value, long currentTime)

Specifies 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 as Long#MAX_VALUE.

Note

The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a timestamp, the current time should be obtained independently.

Parameters
key:K

the key represented by this entry

value:V

the value represented by this entry

currentTime:long

the current time, in nanoseconds

Returns:long

the length of time before the entry expires, in nanoseconds

expireAfterReadback to summary
public long expireAfterRead(K key, V value, long currentTime, @NonNegative long currentDuration)

Specifies 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 as Long#MAX_VALUE. The currentDuration may be returned to not modify the expiration time.

Note

The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a timestamp, the current time should be obtained independently.

Parameters
key:K

the key represented by this entry

value:V

the value represented by this entry

currentTime:long

the current time, in nanoseconds

currentDuration:@NonNegative long

the current duration, in nanoseconds

Returns:long

the length of time before the entry expires, in nanoseconds

expireAfterUpdateback to summary
public long expireAfterUpdate(K key, V value, long currentTime, @NonNegative long currentDuration)

Specifies 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 as Long#MAX_VALUE. The currentDuration may be returned to not modify the expiration time.

Note

The currentTime is supplied by the configured Ticker and by default does not relate to system or wall-clock time. When calculating the duration based on a timestamp, the current time should be obtained independently.

Parameters
key:K

the key represented by this entry

value:V

the value represented by this entry

currentTime:long

the current time, in nanoseconds

currentDuration:@NonNegative long

the current duration, in nanoseconds

Returns:long

the length of time before the entry expires, in nanoseconds