Class BoundedLocalCache.BoundedPolicy<K,V>
- java.lang.Object
-
- com.github.benmanes.caffeine.cache.BoundedLocalCache.BoundedPolicy<K,V>
-
- All Implemented Interfaces:
Policy<K,V>
- Enclosing class:
- BoundedLocalCache<K,V>
static final class BoundedLocalCache.BoundedPolicy<K,V> extends java.lang.Object implements Policy<K,V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
BoundedLocalCache.BoundedPolicy.BoundedEviction
(package private) class
BoundedLocalCache.BoundedPolicy.BoundedExpireAfterAccess
(package private) class
BoundedLocalCache.BoundedPolicy.BoundedExpireAfterWrite
(package private) class
BoundedLocalCache.BoundedPolicy.BoundedRefreshAfterWrite
(package private) class
BoundedLocalCache.BoundedPolicy.BoundedVarExpiration
-
Nested classes/interfaces inherited from interface com.github.benmanes.caffeine.cache.Policy
Policy.Eviction<K,V>, Policy.Expiration<K,V>, Policy.VarExpiration<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) @Nullable java.util.Optional<Policy.Expiration<K,V>>
afterAccess
(package private) @Nullable java.util.Optional<Policy.Expiration<K,V>>
afterWrite
(package private) BoundedLocalCache<K,V>
cache
(package private) @Nullable java.util.Optional<Policy.Eviction<K,V>>
eviction
(package private) boolean
isWeighted
(package private) @Nullable java.util.Optional<Policy.Expiration<K,V>>
refreshes
(package private) java.util.function.Function<V,V>
transformer
(package private) @Nullable java.util.Optional<Policy.VarExpiration<K,V>>
variable
-
Constructor Summary
Constructors Constructor Description BoundedPolicy(BoundedLocalCache<K,V> cache, java.util.function.Function<V,V> transformer, boolean isWeighted)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<Policy.Eviction<K,V>>
eviction()
Returns access to perform operations based on the maximum size or maximum weight eviction policy.java.util.Optional<Policy.Expiration<K,V>>
expireAfterAccess()
Returns access to perform operations based on the time-to-idle expiration policy.java.util.Optional<Policy.Expiration<K,V>>
expireAfterWrite()
Returns access to perform operations based on the time-to-live expiration policy.java.util.Optional<Policy.VarExpiration<K,V>>
expireVariably()
Returns access to perform operations based on the variable expiration policy.@Nullable V
getIfPresentQuietly(java.lang.Object key)
Returns the value associated with thekey
in this cache, ornull
if there is no cached value for thekey
.boolean
isRecordingStats()
Returns whether the cache statistics are being accumulated.java.util.Optional<Policy.Expiration<K,V>>
refreshAfterWrite()
Returns access to perform operations based on the time-to-live refresh policy.
-
-
-
Field Detail
-
cache
final BoundedLocalCache<K,V> cache
-
isWeighted
final boolean isWeighted
-
eviction
@Nullable java.util.Optional<Policy.Eviction<K,V>> eviction
-
refreshes
@Nullable java.util.Optional<Policy.Expiration<K,V>> refreshes
-
afterWrite
@Nullable java.util.Optional<Policy.Expiration<K,V>> afterWrite
-
afterAccess
@Nullable java.util.Optional<Policy.Expiration<K,V>> afterAccess
-
variable
@Nullable java.util.Optional<Policy.VarExpiration<K,V>> variable
-
-
Constructor Detail
-
BoundedPolicy
BoundedPolicy(BoundedLocalCache<K,V> cache, java.util.function.Function<V,V> transformer, boolean isWeighted)
-
-
Method Detail
-
isRecordingStats
public boolean isRecordingStats()
Description copied from interface:Policy
Returns whether the cache statistics are being accumulated.- Specified by:
isRecordingStats
in interfacePolicy<K,V>
- Returns:
- if cache statistics are being recorded
-
getIfPresentQuietly
public @Nullable V getIfPresentQuietly(java.lang.Object key)
Description copied from interface:Policy
Returns the value associated with thekey
in this cache, ornull
if there is no cached value for thekey
. UnlikeCache.getIfPresent(Object)
, this method does not produce any side effects such as updating statistics, the eviction policy, reseting the expiration time, or triggering a refresh.- Specified by:
getIfPresentQuietly
in interfacePolicy<K,V>
- Parameters:
key
- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
null
if this cache contains no mapping for the key
-
eviction
public java.util.Optional<Policy.Eviction<K,V>> eviction()
Description copied from interface:Policy
Returns access to perform operations based on the maximum size or maximum weight eviction policy. If the cache was not constructed with a size-based bound or the implementation does not support these operations, an emptyOptional
is returned.
-
expireAfterAccess
public java.util.Optional<Policy.Expiration<K,V>> expireAfterAccess()
Description copied from interface:Policy
Returns access to perform operations based on the time-to-idle expiration policy. This policy determines that an entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last access. Access time is reset by all cache read and write operations (includingCache.asMap().get(Object)
andCache.asMap().put(K, V)
), but not by operations on the collection-views ofCache.asMap()
.If the cache was not constructed with access-based expiration or the implementation does not support these operations, an empty
Optional
is returned.- Specified by:
expireAfterAccess
in interfacePolicy<K,V>
- Returns:
- access to low-level operations for this cache if a time-to-idle expiration policy is used
-
expireAfterWrite
public java.util.Optional<Policy.Expiration<K,V>> expireAfterWrite()
Description copied from interface:Policy
Returns access to perform operations based on the time-to-live expiration policy. This policy determines that an entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.If the cache was not constructed with write-based expiration or the implementation does not support these operations, an empty
Optional
is returned.- Specified by:
expireAfterWrite
in interfacePolicy<K,V>
- Returns:
- access to low-level operations for this cache if a time-to-live expiration policy is used
-
expireVariably
public java.util.Optional<Policy.VarExpiration<K,V>> expireVariably()
Description copied from interface:Policy
Returns access to perform operations based on the variable expiration policy. This policy determines that an entry should be automatically removed from the cache once a per-entry duration has elapsed.If the cache was not constructed with variable expiration or the implementation does not support these operations, an empty
Optional
is returned.- Specified by:
expireVariably
in interfacePolicy<K,V>
- Returns:
- access to low-level operations for this cache if a variable expiration policy is used
-
refreshAfterWrite
public java.util.Optional<Policy.Expiration<K,V>> refreshAfterWrite()
Description copied from interface:Policy
Returns access to perform operations based on the time-to-live refresh policy. This policy determines that an entry should be automatically reloaded once a fixed duration has elapsed after the entry's creation, or the most recent replacement of its value.If the cache was not constructed with write-based refresh or the implementation does not support these operations, an empty
Optional
is returned.- Specified by:
refreshAfterWrite
in interfacePolicy<K,V>
- Returns:
- access to low-level operations for this cache if a time-to-live refresh policy is used
-
-