Class Cache2kConfig<K,V>
- java.lang.Object
-
- org.cache2k.config.Cache2kConfig<K,V>
-
- All Implemented Interfaces:
BeanMarker
,ConfigBean<Cache2kConfig<K,V>,Cache2kBuilder<K,V>>
,ConfigWithSections
,DataAware<K,V>
public class Cache2kConfig<K,V> extends Object implements ConfigBean<Cache2kConfig<K,V>,Cache2kBuilder<K,V>>, DataAware<K,V>, ConfigWithSections
Configuration for a cache2k cache.To create a cache, the
Cache2kBuilder
is used. All configuration properties are present on the builder and are documented in this place. Consequently, all properties refer to the corresponding builder method.The configuration bean is designed to be serializable. This is used for example to copy default configurations. The builder allows object references to customizations to be set. If this happens the configuration is not serializable. Such configuration is only used for immediate creation of one cache via the builder.
The configuration may contain additional beans, called configuration sections, that are used to configure extensions.
Within the XML configuration of a cache manager different default configuration values may be specified. To get a configuration bean with the effective defaults of a specific manager do
Cache2kBuilder.forUnknownTypes().manager(...).toConfiguration()
- Author:
- Jens Wilke
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_ENTRY_CAPACITY
Default entry capacity of a cache.static Duration
EXPIRY_ETERNAL
A marker duration used insetExpireAfterWrite(Duration)
, to request eternal expiry.static int
UNSET_INT
Constant for unset parameter value.static long
UNSET_LONG
Constant for unset parameter value.
-
Constructor Summary
Constructors Constructor Description Cache2kConfig()
-
Method Summary
-
-
-
Field Detail
-
EXPIRY_ETERNAL
public static final Duration EXPIRY_ETERNAL
A marker duration used insetExpireAfterWrite(Duration)
, to request eternal expiry. The maximum duration after the duration is considered as eternal for our purposes.
-
DEFAULT_ENTRY_CAPACITY
public static final long DEFAULT_ENTRY_CAPACITY
Default entry capacity of a cache. If no capacity is configured the cache uses the default of 1802.- See Also:
- Constant Field Values
-
UNSET_INT
public static final int UNSET_INT
Constant for unset parameter value.- See Also:
- Constant Field Values
-
UNSET_LONG
public static final long UNSET_LONG
Constant for unset parameter value.- See Also:
- Constant Field Values
-
-
Method Detail
-
of
public static <K,V> Cache2kConfig<K,V> of(Class<K> keyType, Class<V> valueType)
Construct a config instance setting the type parameters and returning a proper generic type.
-
of
public static <K,V> Cache2kConfig<K,V> of(CacheType<K> keyType, CacheType<V> valueType)
Construct a config instance setting the type parameters and returning a proper generic type.
-
getName
@Nullable public @Nullable String getName()
- See Also:
Cache2kBuilder.name(String)
-
setName
public void setName(@Nullable @Nullable String name)
- See Also:
Cache2kBuilder.name(String)
-
isNameWasGenerated
public boolean isNameWasGenerated()
True if name is generated and not set by the cache client.
-
setNameWasGenerated
public void setNameWasGenerated(boolean v)
-
getEntryCapacity
public long getEntryCapacity()
- See Also:
Cache2kBuilder.entryCapacity(long)
-
setEntryCapacity
public void setEntryCapacity(long v)
-
isRefreshAhead
public boolean isRefreshAhead()
- See Also:
Cache2kBuilder.refreshAhead(boolean)
-
setRefreshAhead
public void setRefreshAhead(boolean v)
- See Also:
Cache2kBuilder.refreshAhead(boolean)
-
setExpireAfterWrite
public void setExpireAfterWrite(@Nullable @Nullable Duration v)
Sets expire after write. The value is capped atEXPIRY_ETERNAL
, meaning an equal or higher duration is treated as eternal expiry.
-
setIdleScanTime
public void setIdleScanTime(@Nullable @Nullable Duration v)
- See Also:
Cache2kBuilder.idleScanTime(Duration)
-
isEternal
public boolean isEternal()
-
setEternal
public void setEternal(boolean v)
- See Also:
Cache2kBuilder.eternal(boolean)
-
setTimerLag
public void setTimerLag(@Nullable @Nullable Duration v)
- See Also:
Cache2kBuilder.timerLag(Duration)
-
isKeepDataAfterExpired
public boolean isKeepDataAfterExpired()
-
getMaximumWeight
public long getMaximumWeight()
-
setMaximumWeight
public void setMaximumWeight(long v)
- See Also:
Cache2kBuilder.maximumWeight(long)
-
setKeepDataAfterExpired
public void setKeepDataAfterExpired(boolean v)
-
isSharpExpiry
public boolean isSharpExpiry()
-
setSharpExpiry
public void setSharpExpiry(boolean v)
- See Also:
Cache2kBuilder.sharpExpiry(boolean)
-
isExternalConfigurationPresent
public boolean isExternalConfigurationPresent()
An external configuration for the cache was found and is applied. This istrue
if default values are set via the XML configuration or if there is a specific section for the cache name.
-
setExternalConfigurationPresent
public void setExternalConfigurationPresent(boolean v)
-
getSections
public SectionContainer getSections()
Mutable collection of additional configuration sections- Specified by:
getSections
in interfaceConfigWithSections
-
setSections
public void setSections(Collection<ConfigSection<?,?>> c)
Adds the collection of sections to the existing list. This method is intended to improve integration with bean configuration mechanisms that use the set method and construct a set or list, like Springs' bean XML configuration.
-
getLoader
@Nullable public @Nullable CustomizationSupplier<? extends CacheLoader<K,V>> getLoader()
-
setLoader
public void setLoader(@Nullable @Nullable CustomizationSupplier<? extends CacheLoader<K,V>> v)
-
getAdvancedLoader
@Nullable public @Nullable CustomizationSupplier<? extends AdvancedCacheLoader<K,V>> getAdvancedLoader()
-
setAdvancedLoader
public void setAdvancedLoader(@Nullable @Nullable CustomizationSupplier<? extends AdvancedCacheLoader<K,V>> v)
-
getAsyncLoader
@Nullable public @Nullable CustomizationSupplier<? extends AsyncCacheLoader<K,V>> getAsyncLoader()
-
setAsyncLoader
public void setAsyncLoader(@Nullable @Nullable CustomizationSupplier<? extends AsyncCacheLoader<K,V>> v)
- See Also:
Cache2kBuilder.loader(AsyncCacheLoader)
-
getLoaderThreadCount
public int getLoaderThreadCount()
-
setLoaderThreadCount
public void setLoaderThreadCount(int v)
- See Also:
Cache2kBuilder.loaderThreadCount(int)
-
getExpiryPolicy
@Nullable public @Nullable CustomizationSupplier<? extends ExpiryPolicy<? super K,? super V>> getExpiryPolicy()
-
setExpiryPolicy
public void setExpiryPolicy(@Nullable @Nullable CustomizationSupplier<? extends ExpiryPolicy<? super K,? super V>> v)
-
getWriter
@Nullable public @Nullable CustomizationSupplier<? extends CacheWriter<K,V>> getWriter()
-
setWriter
public void setWriter(@Nullable @Nullable CustomizationSupplier<? extends CacheWriter<K,V>> v)
- See Also:
Cache2kBuilder.writer(CacheWriter)
-
isStoreByReference
public boolean isStoreByReference()
-
setStoreByReference
public void setStoreByReference(boolean v)
- See Also:
Cache2kBuilder.storeByReference(boolean)
-
getExceptionPropagator
@Nullable public @Nullable CustomizationSupplier<? extends ExceptionPropagator<? super K,? super V>> getExceptionPropagator()
-
setExceptionPropagator
public void setExceptionPropagator(@Nullable @Nullable CustomizationSupplier<? extends ExceptionPropagator<? super K,? super V>> v)
-
getListeners
@NonNull public @NonNull Collection<CustomizationSupplier<CacheEntryOperationListener<K,V>>> getListeners()
A set of listeners. Listeners added in this collection will be executed in a synchronous mode, meaning, further processing for an entry will stall until a registered listener is executed.A listener can be added by adding it to the collection. Duplicate (in terms of equal objects) listeners will be ignored.
- Returns:
- Mutable collection of listeners
-
hasListeners
public boolean hasListeners()
- Returns:
- True if listeners are added to this configuration.
-
setListeners
public void setListeners(Collection<CustomizationSupplier<CacheEntryOperationListener<K,V>>> c)
Adds the collection of customizations to the existing list. This method is intended to improve integration with bean configuration mechanisms that use the set method and construct a set or list, like Springs' bean XML configuration.
-
getAsyncListeners
@NonNull public @NonNull Collection<CustomizationSupplier<CacheEntryOperationListener<K,V>>> getAsyncListeners()
A set of listeners. A listener can be added by adding it to the collection. Duplicate (in terms of equal objects) listeners will be ignored.- Returns:
- Mutable collection of listeners
-
hasAsyncListeners
public boolean hasAsyncListeners()
- Returns:
- True if listeners are added to this configuration.
-
setAsyncListeners
public void setAsyncListeners(Collection<CustomizationSupplier<CacheEntryOperationListener<K,V>>> c)
Adds the collection of customizations to the existing list. This method is intended to improve integration with bean configuration mechanisms that use the set method and construct a set or list, like Springs' bean XML configuration.
-
getLifecycleListeners
@NonNull public @NonNull Collection<CustomizationSupplier<? extends CacheLifecycleListener>> getLifecycleListeners()
A set of listeners. A listener can be added by adding it to the collection. Duplicate (in terms of equal objects) listeners will be ignored.- Returns:
- Mutable collection of listeners
-
hasLifecycleListeners
public boolean hasLifecycleListeners()
- Returns:
- True if listeners are added to this configuration.
-
setLifecycleListeners
public void setLifecycleListeners(@NonNull @NonNull Collection<CustomizationSupplier<? extends CacheLifecycleListener>> c)
Adds the collection of customizations to the existing list. This method is intended to improve integration with bean configuration mechanisms that use the set method and construct a set or list, like Springs' bean XML configuration.
-
hasFeatures
public boolean hasFeatures()
-
getResiliencePolicy
@Nullable public @Nullable CustomizationSupplier<? extends ResiliencePolicy<? super K,? super V>> getResiliencePolicy()
-
setResiliencePolicy
public void setResiliencePolicy(@Nullable @Nullable CustomizationSupplier<? extends ResiliencePolicy<? super K,? super V>> v)
-
isStrictEviction
public boolean isStrictEviction()
-
setStrictEviction
public void setStrictEviction(boolean v)
- See Also:
Cache2kBuilder.strictEviction(boolean)
-
isPermitNullValues
public boolean isPermitNullValues()
-
setPermitNullValues
public void setPermitNullValues(boolean v)
- See Also:
Cache2kBuilder.permitNullValues(boolean)
-
isDisableStatistics
public boolean isDisableStatistics()
-
setDisableStatistics
public void setDisableStatistics(boolean v)
-
getLoaderExecutor
@Nullable public @Nullable CustomizationSupplier<? extends Executor> getLoaderExecutor()
-
setLoaderExecutor
public void setLoaderExecutor(@Nullable @Nullable CustomizationSupplier<? extends Executor> v)
- See Also:
Cache2kBuilder.loaderExecutor(Executor)
-
isRecordModificationTime
public boolean isRecordModificationTime()
-
setRecordModificationTime
public void setRecordModificationTime(boolean v)
-
getRefreshExecutor
@Nullable public @Nullable CustomizationSupplier<? extends Executor> getRefreshExecutor()
-
setRefreshExecutor
public void setRefreshExecutor(@Nullable @Nullable CustomizationSupplier<? extends Executor> v)
- See Also:
Cache2kBuilder.refreshExecutor(Executor)
-
getExecutor
@Nullable public @Nullable CustomizationSupplier<? extends Executor> getExecutor()
-
setExecutor
public void setExecutor(@Nullable @Nullable CustomizationSupplier<? extends Executor> v)
- See Also:
Cache2kBuilder.executor(Executor)
-
getAsyncListenerExecutor
@Nullable public @Nullable CustomizationSupplier<? extends Executor> getAsyncListenerExecutor()
-
setAsyncListenerExecutor
public void setAsyncListenerExecutor(@Nullable @Nullable CustomizationSupplier<? extends Executor> v)
-
setWeigher
public void setWeigher(@Nullable @Nullable CustomizationSupplier<? extends Weigher<K,V>> v)
- See Also:
Cache2kBuilder.weigher(Weigher)
-
getScheduler
@Nullable public @Nullable CustomizationSupplier<? extends Scheduler> getScheduler()
-
setScheduler
public void setScheduler(CustomizationSupplier<? extends Scheduler> scheduler)
-
getTimeReference
@Nullable public @Nullable CustomizationSupplier<? extends TimeReference> getTimeReference()
-
setTimeReference
public void setTimeReference(CustomizationSupplier<? extends TimeReference> timeReference)
-
isBoostConcurrency
public boolean isBoostConcurrency()
-
setBoostConcurrency
public void setBoostConcurrency(boolean v)
- See Also:
Cache2kBuilder.boostConcurrency(boolean)
-
isDisableMonitoring
public boolean isDisableMonitoring()
-
setDisableMonitoring
public void setDisableMonitoring(boolean disableMonitoring)
-
getTraceCacheWrapper
@Nullable public @Nullable CacheWrapper getTraceCacheWrapper()
-
setTraceCacheWrapper
public void setTraceCacheWrapper(@Nullable @Nullable CacheWrapper traceCacheWrapper)
- See Also:
CacheWrapper
-
getCacheWrapper
@Nullable public @Nullable CacheWrapper getCacheWrapper()
-
setCacheWrapper
public void setCacheWrapper(@Nullable @Nullable CacheWrapper cacheWrapper)
- See Also:
CacheWrapper
-
builder
public Cache2kBuilder<K,V> builder()
Creates a cache builder from the configuration.- Specified by:
builder
in interfaceConfigBean<K,V>
-
-