Interface CacheProviderFactory<K,V>
- Type Parameters:
K
- the type of cache keyV
- the type of cache entries
- All Known Implementing Classes:
CaffeineCacheProviderFactory
public interface CacheProviderFactory<K,V>
Interface to create instances of
CacheProvider
.- Author:
- Chris Bono
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Interface for a cache eviction listener. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(Duration cacheExpireAfterAccess, Long cacheMaximumSize, Integer cacheInitialCapacity, CacheProviderFactory.EvictionListener<K, V> evictionListener) Create a cache provider instance with the specified options.static <K,
V> CacheProviderFactory<K, V> load()
Uses the Java ServiceLoader API to find the first available cache provider factory.
-
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 cachecacheMaximumSize
- maximum size of cache (entries)cacheInitialCapacity
- the initial size of cacheevictionListener
- listener called when an entry is evicted from the cache- Returns:
- cache provider instance
-
load
Uses the Java ServiceLoader API to find the first available cache provider factory.- Type Parameters:
K
- the type of cache keyV
- the type of cache entries- Returns:
- the cache provider factory service
- Throws:
IllegalStateException
- if no factory was found
-