Module com.github.benmanes.caffeine
Interface Policy.FixedRefresh<K,V>
- Type Parameters:
K- the type of keysV- the type of values
public static interface Policy.FixedRefresh<K,V>
The low-level operations for a cache with a fixed refresh policy.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the age of the entry based on the refresh policy.Returns the age of the entry based on the refresh policy.default DurationReturns the fixed duration used to determine if an entry should be eligible for reloading due to elapsing this time bound.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(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 Details
-
ageOf
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
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
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
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
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
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
-