Class CaffeineConfiguration<K,V>
java.lang.Object
com.github.benmanes.caffeine.jcache.configuration.CaffeineConfiguration<K,V>
- All Implemented Interfaces:
Serializable
,javax.cache.configuration.CompleteConfiguration<K,
,V> javax.cache.configuration.Configuration<K,
V>
public final class CaffeineConfiguration<K,V>
extends Object
implements javax.cache.configuration.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 Cache
API boundary. If enabled and the Copier
is not explicitly
set, then the JavaSerializationCopier
will be used. This differs from
MutableConfiguration
which enables store by value at construction.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final javax.cache.configuration.Factory
<Executor> private javax.cache.configuration.Factory
<Copier> private static final javax.cache.configuration.Factory
<Scheduler> private javax.cache.configuration.Factory
<Executor> private @Nullable Long
private @Nullable Long
private static final javax.cache.configuration.Factory
<Copier> private @Nullable Long
private @Nullable Long
private boolean
private @Nullable Long
private javax.cache.configuration.Factory
<Scheduler> private static final long
private static final javax.cache.configuration.Factory
<Ticker> private javax.cache.configuration.Factory
<Ticker> -
Constructor Summary
ConstructorsConstructorDescriptionCaffeineConfiguration
(javax.cache.configuration.CompleteConfiguration<K, V> configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCacheEntryListenerConfiguration
(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) SeeMutableConfiguration.addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>)
.boolean
javax.cache.configuration.Factory
<Copier> Returns theFactory
for theCopier
to be used for the cache.javax.cache.configuration.Factory
<Executor> Returns theFactory
for theExecutor
to be used for the cache.Returns the expire after access in nanoseconds.Returns the expire after write in nanoseconds.Returns theFactory
for theExpiry
to be used for the cache.javax.cache.configuration.Factory
<javax.cache.expiry.ExpiryPolicy> Returns the maximum size to be used for the cache.Returns the maximum weight to be used for the cache.Returns the refresh after write in nanoseconds.javax.cache.configuration.Factory
<Scheduler> Returns theFactory
for theScheduler
to be used for the cache.javax.cache.configuration.Factory
<Ticker> Returns theFactory
for theTicker
to be used for the cache.Returns theFactory
for theWeigher
to be used for the cache.boolean
int
hashCode()
boolean
SeeMutableConfiguration.isManagementEnabled
.boolean
Checks whether native statistics collection is enabled in this cache.boolean
boolean
boolean
boolean
void
removeCacheEntryListenerConfiguration
(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) SeeMutableConfiguration.removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>)
.void
setCacheLoaderFactory
(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> factory) SeeMutableConfiguration.setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>>)
.void
setCacheWriterFactory
(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>> factory) SeeMutableConfiguration.setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>>)
.void
setCopierFactory
(javax.cache.configuration.Factory<Copier> factory) Set theFactory
for theCopier
.void
setExecutorFactory
(javax.cache.configuration.Factory<Executor> factory) Set theFactory
for theExecutor
.void
setExpireAfterAccess
(OptionalLong expireAfterAccessNanos) Set the expire after write in nanoseconds.void
setExpireAfterWrite
(OptionalLong expireAfterWriteNanos) Set the expire after write in nanoseconds.void
setExpiryFactory
(Optional<javax.cache.configuration.Factory<? extends Expiry<K, V>>> factory) Set theFactory
for theExpiry
.void
setExpiryPolicyFactory
(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory) SeeMutableConfiguration.setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy>)
.void
setManagementEnabled
(boolean enabled) SeeMutableConfiguration.setManagementEnabled(boolean)
.void
setMaximumSize
(OptionalLong maximumSize) Set the maximum size.void
setMaximumWeight
(OptionalLong maximumWeight) Set the maximum weight.void
setNativeStatisticsEnabled
(boolean enabled) Sets whether native statistics gathering is enabled on a cache.void
setReadThrough
(boolean isReadThrough) SeeMutableConfiguration.setReadThrough(boolean)
.void
setRefreshAfterWrite
(OptionalLong refreshAfterWriteNanos) Set the refresh after write in nanoseconds.void
setSchedulerFactory
(javax.cache.configuration.Factory<Scheduler> factory) Set theFactory
for theScheduler
.void
setStatisticsEnabled
(boolean enabled) SeeMutableConfiguration.setStatisticsEnabled(boolean)
.void
setStoreByValue
(boolean isStoreByValue) SeeMutableConfiguration.setStoreByValue(boolean)
.void
setTickerFactory
(javax.cache.configuration.Factory<Ticker> factory) Set theFactory
for theTicker
.void
SeeMutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>)
.void
setWeigherFactory
(Optional<javax.cache.configuration.Factory<? extends Weigher<K, V>>> factory) Set theFactory
for theWeigher
.void
setWriteThrough
(boolean isWriteThrough) SeeMutableConfiguration.setWriteThrough(boolean)
.
-
Field Details
-
DISABLED_SCHEDULER
-
JAVA_COPIER
-
COMMON_POOL
-
SYSTEM_TICKER
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
delegate
-
weigherFactory
-
expiryFactory
-
schedulerFactory
-
executorFactory
-
copierFactory
-
tickerFactory
-
refreshAfterWriteNanos
-
expireAfterAccessNanos
-
expireAfterWriteNanos
-
maximumWeight
-
maximumSize
-
nativeStatistics
private boolean nativeStatistics
-
-
Constructor Details
-
CaffeineConfiguration
public CaffeineConfiguration() -
CaffeineConfiguration
-
-
Method Details
-
getKeyType
-
getValueType
-
setTypes
SeeMutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>)
. -
getCacheEntryListenerConfigurations
-
addCacheEntryListenerConfiguration
public void addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) SeeMutableConfiguration.addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>)
. -
removeCacheEntryListenerConfiguration
public void removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) SeeMutableConfiguration.removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>)
. -
getCacheLoaderFactory
-
setCacheLoaderFactory
public void setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>> factory) SeeMutableConfiguration.setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K, V>>)
. -
getCacheWriterFactory
-
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
public void setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>> factory) SeeMutableConfiguration.setCacheWriterFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K, ? super V>>)
. -
getExpiryPolicyFactory
public javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy> getExpiryPolicyFactory() -
setExpiryPolicyFactory
public void setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory) SeeMutableConfiguration.setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy>)
. -
isReadThrough
public boolean isReadThrough() -
setReadThrough
public void setReadThrough(boolean isReadThrough) SeeMutableConfiguration.setReadThrough(boolean)
. -
isWriteThrough
public boolean isWriteThrough() -
setWriteThrough
public void setWriteThrough(boolean isWriteThrough) SeeMutableConfiguration.setWriteThrough(boolean)
. -
isStoreByValue
public boolean isStoreByValue() -
setStoreByValue
public void setStoreByValue(boolean isStoreByValue) SeeMutableConfiguration.setStoreByValue(boolean)
. -
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
public void setNativeStatisticsEnabled(boolean enabled) Sets whether native statistics gathering is enabled on a cache.- Parameters:
enabled
- true to enable native statistics, false to disable.
-
isStatisticsEnabled
public boolean isStatisticsEnabled() -
setStatisticsEnabled
public void setStatisticsEnabled(boolean enabled) SeeMutableConfiguration.setStatisticsEnabled(boolean)
. -
isManagementEnabled
public boolean isManagementEnabled()SeeMutableConfiguration.isManagementEnabled
. -
setManagementEnabled
public void setManagementEnabled(boolean enabled) SeeMutableConfiguration.setManagementEnabled(boolean)
. -
getCopierFactory
Returns theFactory
for theCopier
to be used for the cache.- Returns:
- the
Factory
for theCopier
-
setCopierFactory
Set theFactory
for theCopier
.- Parameters:
factory
- theCopier
Factory
-
getSchedulerFactory
Returns theFactory
for theScheduler
to be used for the cache.- Returns:
- the
Factory
for theScheduler
-
setSchedulerFactory
Set theFactory
for theScheduler
.- Parameters:
factory
- theScheduler
Factory
-
getTickerFactory
Returns theFactory
for theTicker
to be used for the cache.- Returns:
- the
Factory
for theTicker
-
setTickerFactory
Set theFactory
for theTicker
.- Parameters:
factory
- theTicker
Factory
-
getExecutorFactory
Returns theFactory
for theExecutor
to be used for the cache.- Returns:
- the
Factory
for theExecutor
-
setExecutorFactory
Set theFactory
for theExecutor
.- Parameters:
factory
- theExecutor
Factory
-
getRefreshAfterWrite
Returns the refresh after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setRefreshAfterWrite
Set the refresh after write in nanoseconds.- Parameters:
refreshAfterWriteNanos
- the duration in nanoseconds
-
getExpireAfterWrite
Returns the expire after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterWrite
Set the expire after write in nanoseconds.- Parameters:
expireAfterWriteNanos
- the duration in nanoseconds
-
getExpireAfterAccess
Returns the expire after access in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterAccess
Set the expire after write in nanoseconds.- Parameters:
expireAfterAccessNanos
- the duration in nanoseconds
-
getExpiryFactory
Returns theFactory
for theExpiry
to be used for the cache.- Returns:
- the
Factory
for theExpiry
-
setExpiryFactory
public void setExpiryFactory(Optional<javax.cache.configuration.Factory<? extends Expiry<K, V>>> factory) Set theFactory
for theExpiry
.- Parameters:
factory
- theExpiry
Factory
-
setMaximumSize
Set the maximum size.- Parameters:
maximumSize
- the maximum size
-
getMaximumSize
Returns the maximum size to be used for the cache.- Returns:
- the maximum size
-
setMaximumWeight
Set the maximum weight.- Parameters:
maximumWeight
- the maximum weighted size
-
getMaximumWeight
Returns the maximum weight to be used for the cache.- Returns:
- the maximum weight
-
getWeigherFactory
Returns theFactory
for theWeigher
to be used for the cache.- Returns:
- the
Factory
for theWeigher
-
setWeigherFactory
public void setWeigherFactory(Optional<javax.cache.configuration.Factory<? extends Weigher<K, V>>> factory) Set theFactory
for theWeigher
.- Parameters:
factory
- theWeigher
Factory
-
equals
-
hashCode
public int hashCode()
-