Module com.github.benmanes.caffeine
Interface Policy.FixedRefresh<K,V>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default Optional<Duration>ageOf(K key)Returns the age of the entry based on the refresh policy.OptionalLongageOf(K key, TimeUnit unit)Returns the age of the entry based on the refresh policy.default DurationgetRefreshesAfter()Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound.@org.checkerframework.checker.index.qual.NonNegative longgetRefreshesAfter(TimeUnit unit)Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound.voidsetRefreshesAfter(@org.checkerframework.checker.index.qual.NonNegative long duration, TimeUnit unit)Specifies that each entry should be eligible for reloading once a fixed duration has elapsed.default voidsetRefreshesAfter(Duration duration)Specifies that each entry should be eligible for reloading once a fixed duration has elapsed.
-
-
-
Method Detail
-
ageOf
OptionalLong ageOf(K key, TimeUnit unit)
Returns the age of the entry based on the refresh policy. The entry's age is the cache's estimate of the amount of time since the entry's refresh period was last reset.A refresh policy uses the age to determine if an entry is fresh or stale by comparing it to the freshness lifetime. This is calculated as
fresh = freshnessLifetime > agewherefreshnessLifetime = expires - currentTime.- Parameters:
key- the key for the entry being queriedunit- the unit thatageis expressed in- Returns:
- the age if the entry is present in the cache
- Throws:
NullPointerException- if the specified key or unit is null
-
ageOf
default Optional<Duration> ageOf(K key)
Returns the age of the entry based on the refresh policy. The entry's age is the cache's estimate of the amount of time since the entry's refresh period was last reset.A refresh policy uses the age to determine if an entry is fresh or stale by comparing it to the freshness lifetime. This is calculated as
fresh = freshnessLifetime > agewherefreshnessLifetime = expires - currentTime.- Parameters:
key- the key for the entry being queried- Returns:
- the age if the entry is present in the cache
- Throws:
NullPointerException- if the specified key is null
-
getRefreshesAfter
@org.checkerframework.checker.index.qual.NonNegative long getRefreshesAfter(TimeUnit unit)
Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound. An entry is considered fresh if its age is less than this duration, and stale otherwise. The refresh policy determines when the entry's age is reset.- Parameters:
unit- the unit that duration is expressed in- Returns:
- the length of time after which an entry is eligible to be reloaded
- Throws:
NullPointerException- if the unit is null
-
getRefreshesAfter
default Duration getRefreshesAfter()
Returns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound. An entry is considered fresh if its age is less than this duration, and stale otherwise. The refresh policy determines when the entry's age is reset.- Returns:
- the length of time after which an entry is eligible to be reloaded
-
setRefreshesAfter
void setRefreshesAfter(@org.checkerframework.checker.index.qual.NonNegative long duration, TimeUnit unit)Specifies that each entry should be eligible for reloading once a fixed duration has elapsed. The refresh policy determines when the entry's age is reset.- Parameters:
duration- the length of time after which an entry is eligible to be reloadedunit- the unit thatdurationis expressed in- Throws:
IllegalArgumentException- ifdurationis negativeNullPointerException- if the unit is null
-
setRefreshesAfter
default void setRefreshesAfter(Duration duration)
Specifies that each entry should be eligible for reloading once a fixed duration has elapsed. The refresh policy determines when the entry's age is reset.- Parameters:
duration- the length of time after which an entry is eligible to be reloaded- Throws:
IllegalArgumentException- ifdurationis negativeNullPointerException- if the duration is null
-
-