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 Summary

    Modifier and Type Method Description
    @Nullable java.util.concurrent.ScheduledExecutorService executor()
    The scheduler used by the cache.
    @Nullable java.time.Duration expiryTime()
    The entry expiry time.
    @Nullable ExpiryType expiryType()
    The entry expiration policy.
    @Nullable java.lang.Long maxSize()
    The maximum capacity of the cache.
    @NotNull CacheProvider provider()
    The provider of a conforming cache instance.
    @Nullable RemovalListener<K,​V> removalListener()
    The cache entry removal listener.
  • 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 java.lang.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 java.time.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 java.util.concurrent.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