Package io.github.xanthic.cache.core
Class CacheApi
java.lang.Object
io.github.xanthic.cache.core.CacheApi
public final class CacheApi
extends java.lang.Object
Primary API interaction point to build
Cache
instances.- See Also:
create(Consumer)
-
Method Summary
Modifier and Type Method Description static <K, V> io.github.xanthic.cache.api.Cache<K,V>
create(java.util.function.Consumer<CacheApiSpec<K,V>> spec)
Builds a genericCache
according to the desired specification.
-
Method Details
-
create
public static <K, V> io.github.xanthic.cache.api.Cache<K,V> create(java.util.function.Consumer<CacheApiSpec<K,V>> spec)Builds a genericCache
according to the desired specification.- Type Parameters:
K
- the type of keys that form the cacheV
- the type of values that are contained in the cache- Parameters:
spec
- consumer in which the desired cache settings should be specified- Returns:
Cache
- Throws:
io.github.xanthic.cache.api.exception.NoDefaultCacheImplementationException
- if a provider is not specified and no default provider has been setio.github.xanthic.cache.api.exception.MisconfiguredCacheException
- if the cache settings are invalid (e.g., negative max size or expiry time)- See Also:
ICacheSpec
,CacheApiSettings
-