Interface ICacheSpec<K,V>
- Type Parameters:
K
- the type of keys that form the cacheV
- the type of values that are contained in the cache
-
Method Summary
Modifier and TypeMethodDescription@Nullable ScheduledExecutorService
executor()
The scheduler used by the cache.@Nullable Duration
The entry expiry time.@Nullable ExpiryType
The entry expiration policy.default @Nullable Boolean
The forecasted contention of the cache.@Nullable Long
maxSize()
The maximum capacity of the cache.@NotNull CacheProvider
provider()
The provider of a conforming cache instance.@Nullable RemovalListener
<K, V> The cache entry removal listener.
-
Method Details
-
provider
The provider of a conforming cache instance.Library developers should avoid specifying a non-null provider so that end users are given this choice.
- Returns:
- the specific provider that should be used to fulfill the desired cache specification
-
maxSize
The maximum capacity of the cache.Null implies no constraint. Not-null values must be non-negative.
Specifying a not-null value is highly recommended.
- Returns:
- the maximum number of entries that may be contained in the cache
-
expiryTime
The entry expiry time.When specified, it is recommended to also specify
expiryType()
andexecutor()
.- Returns:
- the time to expiry for cache entries
-
expiryType
The entry expiration policy.This has no effect unless
expiryTime()
is specified.- Returns:
- the type of expiration policy that should be applied to the cache
-
removalListener
The cache entry removal listener.For timely eviction events, it is recommended to also specify
executor()
.- Returns:
- the listener to cache entry removals
-
executor
The scheduler used by the cache.When
expiryTime()
is active, providing a not-null executor is highly recommended.- Returns:
- the executor to optionally use for cache operations
-
highContention
The forecasted contention of the cache.If the cache will be mutated by many threads concurrently, this flag can be enabled to hint to certain providers to perform certain internal optimizations to boost performance, which could come at the cost of increased memory usage.
- Returns:
- whether providers should optimize for high contention
-