Interface CacheProviderFactory<K,V>

Type Parameters:
K - the type of cache key
V - the type of cache entries
All Known Implementing Classes:
CaffeineCacheProviderFactory

public interface CacheProviderFactory<K,V>
Interface to create instances of CacheProvider.
Author:
Chris Bono
  • Method Details

    • create

      CacheProvider<K,V> create(Duration cacheExpireAfterAccess, Long cacheMaximumSize, Integer cacheInitialCapacity, CacheProviderFactory.EvictionListener<K,V> evictionListener)
      Create a cache provider instance with the specified options.
      Parameters:
      cacheExpireAfterAccess - time period to expire unused entries in the cache
      cacheMaximumSize - maximum size of cache (entries)
      cacheInitialCapacity - the initial size of cache
      evictionListener - listener called when an entry is evicted from the cache
      Returns:
      cache provider instance
    • load

      static <K, V> CacheProviderFactory<K,V> load()
      Uses the Java ServiceLoader API to find the first available cache provider factory.
      Type Parameters:
      K - the type of cache key
      V - the type of cache entries
      Returns:
      the cache provider factory service
      Throws:
      IllegalStateException - if no factory was found