Class CaffeineConfiguration<K,V>
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.configuration.CaffeineConfiguration<K,V>
-
- All Implemented Interfaces:
Serializable,CompleteConfiguration<K,V>,Configuration<K,V>
public final class CaffeineConfiguration<K,V> extends Object implements CompleteConfiguration<K,V>
A JCache configuration with Caffeine specific settings.The initial settings disable store by value so that entries are not copied when crossing the
CacheAPI boundary. If enabled and theCopieris not explicitly set, then theJavaSerializationCopierwill be used. This differs fromMutableConfigurationwhich enables store by value at construction.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CaffeineConfiguration()CaffeineConfiguration(CompleteConfiguration<K,V> configuration)Returns a modifiable copy of the configuration.
-
Method Summary
-
-
-
Constructor Detail
-
CaffeineConfiguration
public CaffeineConfiguration()
-
CaffeineConfiguration
public CaffeineConfiguration(CompleteConfiguration<K,V> configuration)
Returns a modifiable copy of the configuration.
-
-
Method Detail
-
immutableCopy
public CaffeineConfiguration<K,V> immutableCopy()
Returns an unmodifiable copy of this configuration.
-
getKeyType
public Class<K> getKeyType()
- Specified by:
getKeyTypein interfaceConfiguration<K,V>
-
getValueType
public Class<V> getValueType()
- Specified by:
getValueTypein interfaceConfiguration<K,V>
-
setTypes
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setTypes(Class<K> keyType, Class<V> valueType)
-
getCacheEntryListenerConfigurations
public Iterable<CacheEntryListenerConfiguration<K,V>> getCacheEntryListenerConfigurations()
- Specified by:
getCacheEntryListenerConfigurationsin interfaceCompleteConfiguration<K,V>
-
addCacheEntryListenerConfiguration
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> addCacheEntryListenerConfiguration(CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
-
removeCacheEntryListenerConfiguration
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> removeCacheEntryListenerConfiguration(CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
-
getCacheLoaderFactory
public @Nullable Factory<CacheLoader<K,V>> getCacheLoaderFactory()
- Specified by:
getCacheLoaderFactoryin interfaceCompleteConfiguration<K,V>
-
setCacheLoaderFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setCacheLoaderFactory(Factory<? extends CacheLoader<K,V>> factory)
-
getCacheWriterFactory
public @Nullable Factory<CacheWriter<? super K,? super V>> getCacheWriterFactory()
- Specified by:
getCacheWriterFactoryin interfaceCompleteConfiguration<K,V>
-
getCacheWriter
public @Nullable CacheWriter<K,V> getCacheWriter()
Returns a writer created by the configured factory or null if not set.
-
hasCacheWriter
public boolean hasCacheWriter()
Returns if the cache writer factory is specified.
-
setCacheWriterFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setCacheWriterFactory(Factory<? extends CacheWriter<? super K,? super V>> factory)
-
getExpiryPolicyFactory
public Factory<ExpiryPolicy> getExpiryPolicyFactory()
- Specified by:
getExpiryPolicyFactoryin interfaceCompleteConfiguration<K,V>
-
setExpiryPolicyFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setExpiryPolicyFactory(Factory<? extends ExpiryPolicy> factory)
-
isReadThrough
public boolean isReadThrough()
- Specified by:
isReadThroughin interfaceCompleteConfiguration<K,V>
-
setReadThrough
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setReadThrough(boolean isReadThrough)
-
isWriteThrough
public boolean isWriteThrough()
- Specified by:
isWriteThroughin interfaceCompleteConfiguration<K,V>
-
setWriteThrough
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setWriteThrough(boolean isWriteThrough)
-
isStoreByValue
public boolean isStoreByValue()
- Specified by:
isStoreByValuein interfaceConfiguration<K,V>
-
setStoreByValue
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setStoreByValue(boolean isStoreByValue)
-
isNativeStatisticsEnabled
public boolean isNativeStatisticsEnabled()
Checks whether native statistics collection is enabled in this cache.The default value is
false.- Returns:
- true if native statistics collection is enabled
-
setNativeStatisticsEnabled
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setNativeStatisticsEnabled(boolean enabled)
Sets whether native statistics gathering is enabled on a cache.- Parameters:
enabled- true to enable native statistics, false to disable.- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
isStatisticsEnabled
public boolean isStatisticsEnabled()
- Specified by:
isStatisticsEnabledin interfaceCompleteConfiguration<K,V>
-
setStatisticsEnabled
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setStatisticsEnabled(boolean enabled)
-
isManagementEnabled
public boolean isManagementEnabled()
- Specified by:
isManagementEnabledin interfaceCompleteConfiguration<K,V>
-
setManagementEnabled
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setManagementEnabled(boolean enabled)
-
setCopierFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setCopierFactory(Factory<Copier> factory)
- Parameters:
factory- theCopierFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
setSchedulerFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setSchedulerFactory(Factory<Scheduler> factory)
- Parameters:
factory- theSchedulerFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
setTickerFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setTickerFactory(Factory<Ticker> factory)
- Parameters:
factory- theTickerFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
setExecutorFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setExecutorFactory(Factory<Executor> factory)
- Parameters:
factory- theExecutorFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
getRefreshAfterWrite
public OptionalLong getRefreshAfterWrite()
Returns the refresh after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setRefreshAfterWrite
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setRefreshAfterWrite(OptionalLong refreshAfterWriteNanos)
Set the refresh after write in nanoseconds.- Parameters:
refreshAfterWriteNanos- the duration in nanoseconds- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
getExpireAfterWrite
public OptionalLong getExpireAfterWrite()
Returns the expire after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterWrite
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setExpireAfterWrite(OptionalLong expireAfterWriteNanos)
Set the expire after write in nanoseconds.- Parameters:
expireAfterWriteNanos- the duration in nanoseconds- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
getExpireAfterAccess
public OptionalLong getExpireAfterAccess()
Returns the expire after access in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterAccess
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setExpireAfterAccess(OptionalLong expireAfterAccessNanos)
Set the expire after write in nanoseconds.- Parameters:
expireAfterAccessNanos- the duration in nanoseconds- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
setExpiryFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setExpiryFactory(Optional<Factory<? extends Expiry<K,V>>> factory)
- Parameters:
factory- theExpiryFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
getMaximumSize
public OptionalLong getMaximumSize()
Returns the maximum size to be used for the cache.- Returns:
- the maximum size
-
setMaximumSize
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setMaximumSize(OptionalLong maximumSize)
Set the maximum size.- Parameters:
maximumSize- the maximum size- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
getMaximumWeight
public OptionalLong getMaximumWeight()
Returns the maximum weight to be used for the cache.- Returns:
- the maximum weight
-
setMaximumWeight
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setMaximumWeight(OptionalLong maximumWeight)
Set the maximum weight.- Parameters:
maximumWeight- the maximum weighted size- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
setWeigherFactory
@CanIgnoreReturnValue public CaffeineConfiguration<K,V> setWeigherFactory(Optional<Factory<? extends Weigher<K,V>>> factory)
- Parameters:
factory- theWeigherFactory- Returns:
- the
CaffeineConfigurationto permit fluent-style method calls
-
-