Package io.github.xanthic.cache.core
Class CacheApiSettings
java.lang.Object
io.github.xanthic.cache.core.CacheApiSettings
Holds a registry of default settings and cache providers.
-
Method Summary
Modifier and TypeMethodDescription@NotNull io.github.xanthic.cache.api.CacheProvider
Obtains the default cache provider.io.github.xanthic.cache.api.domain.MisconfigurationPolicy
The default misconfiguration policy.static @NotNull CacheApiSettings
void
registerCacheProvider
(@NonNull Class<? extends io.github.xanthic.cache.api.CacheProvider> cacheProviderClass, @Nullable io.github.xanthic.cache.api.CacheProvider cacheProvider) Registers an available provider for the cache settings.void
setDefaultCacheProvider
(@NotNull io.github.xanthic.cache.api.CacheProvider provider) Sets the default cache provider to use for caches that don't explicitly specify a provider to use.void
setDefaultMisconfigurationPolicy
(io.github.xanthic.cache.api.domain.MisconfigurationPolicy defaultMisconfigurationPolicy) The default misconfiguration policy.
-
Method Details
-
setDefaultCacheProvider
public void setDefaultCacheProvider(@NotNull @NotNull io.github.xanthic.cache.api.CacheProvider provider) Sets the default cache provider to use for caches that don't explicitly specify a provider to use.- Parameters:
provider
- the cache provider to be the new default- Throws:
NullPointerException
- if the provider argument is null
-
getDefaultCacheProvider
@NotNull public @NotNull io.github.xanthic.cache.api.CacheProvider getDefaultCacheProvider()Obtains the default cache provider.- Returns:
- an instance of the default cache provider
- Throws:
io.github.xanthic.cache.api.exception.NoDefaultCacheImplementationException
- if no default has been set- See Also:
-
registerCacheProvider
public void registerCacheProvider(@NonNull @NonNull Class<? extends io.github.xanthic.cache.api.CacheProvider> cacheProviderClass, @Nullable @Nullable io.github.xanthic.cache.api.CacheProvider cacheProvider) Registers an available provider for the cache settings.Further, the default cache provider will be set to this cache provider, if the default has not yet been set.
Note: the cacheProvider parameter can only be null if there is a public no-args constructor for the provider. This allows for lazy initialization of the provider only if it is needed.
- Parameters:
cacheProviderClass
- the class of the providercacheProvider
- an instance of the provider- Throws:
NullPointerException
- if cacheProviderClass is null
-
getInstance
- Returns:
- the cache api settings singleton
-
getDefaultMisconfigurationPolicy
public io.github.xanthic.cache.api.domain.MisconfigurationPolicy getDefaultMisconfigurationPolicy()The default misconfiguration policy.- See Also:
-
MisconfigurationPolicy
-
setDefaultMisconfigurationPolicy
public void setDefaultMisconfigurationPolicy(io.github.xanthic.cache.api.domain.MisconfigurationPolicy defaultMisconfigurationPolicy) The default misconfiguration policy.- See Also:
-
MisconfigurationPolicy
-