Interface ICacheSpec<K,V>

Type Parameters:
K - the type of keys that form the cache
V - the type of values that are contained in the cache

public interface ICacheSpec<K,V>
Cache configuration settings that form a specification that requested implementations should satisfy.
  • Method Details

    • provider

      @NotNull @NotNull CacheProvider 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

      @Nullable @Nullable Long 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

      @Nullable @Nullable Duration expiryTime()
      The entry expiry time.

      When specified, it is recommended to also specify expiryType() and executor().

      Returns:
      the time to expiry for cache entries
    • expiryType

      @Nullable @Nullable ExpiryType 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

      @Nullable @Nullable RemovalListener<K,V> 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

      @Nullable @Nullable ScheduledExecutorService 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

      @Nullable default @Nullable Boolean 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