Interface Policy<K,V>
- All Known Implementing Classes:
BoundedLocalCache.BoundedPolicy
,UnboundedLocalCache.UnboundedPolicy
@ThreadSafe
public interface Policy<K,V>
An access point for inspecting and performing low-level operations based on the cache's runtime
characteristics. These operations are optional and dependent on how the cache was constructed
and what abilities the implementation exposes.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
The low-level operations for a cache with a size-based eviction policy.static interface
The low-level operations for a cache with a expiration policy. -
Method Summary
Modifier and TypeMethodDescriptioneviction()
Returns access to perform operations based on the maximum size or maximum weight eviction policy.Returns access to perform operations based on the time-to-idle expiration policy.Returns access to perform operations based on the time-to-live expiration policy.boolean
Returns whether the cache statistics are being accumulated.Returns access to perform operations based on the time-to-live refresh policy.
-
Method Details
-
isRecordingStats
boolean isRecordingStats()Returns whether the cache statistics are being accumulated.- Returns:
- if cache statistics are being recorded
-
eviction
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.- Returns:
- access to low-level operations for this cache if an eviction policy is used
-
expireAfterAccess
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.- Returns:
- access to low-level operations for this cache if a time-to-idle expiration policy is used
-
expireAfterWrite
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.- Returns:
- access to low-level operations for this cache if a time-to-live expiration policy is used
-
refreshAfterWrite
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.- Returns:
- access to low-level operations for this cache if a time-to-live refresh policy is used
-