Class CaffeineConfiguration<K,V>
- java.lang.Object
-
- com.github.benmanes.caffeine.jcache.configuration.CaffeineConfiguration<K,V>
-
- All Implemented Interfaces:
java.io.Serializable
,javax.cache.configuration.CompleteConfiguration<K,V>
,javax.cache.configuration.Configuration<K,V>
public final class CaffeineConfiguration<K,V> extends java.lang.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 theCopier
is not explicitly set, then theJavaSerializationCopier
will be used. This differs fromMutableConfiguration
which enables store by value at construction.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static javax.cache.configuration.Factory<java.util.concurrent.Executor>
COMMON_POOL
private javax.cache.configuration.Factory<Copier>
copierFactory
private javax.cache.configuration.MutableConfiguration<K,V>
delegate
private static javax.cache.configuration.Factory<Scheduler>
DISABLED_SCHEDULER
private javax.cache.configuration.Factory<java.util.concurrent.Executor>
executorFactory
private @Nullable java.lang.Long
expireAfterAccessNanos
private @Nullable java.lang.Long
expireAfterWriteNanos
private @Nullable javax.cache.configuration.Factory<Expiry<K,V>>
expiryFactory
private static javax.cache.configuration.Factory<Copier>
JAVA_COPIER
private @Nullable java.lang.Long
maximumSize
private @Nullable java.lang.Long
maximumWeight
private boolean
nativeStatistics
private @Nullable java.lang.Long
refreshAfterWriteNanos
private javax.cache.configuration.Factory<Scheduler>
schedulerFactory
private static long
serialVersionUID
private static javax.cache.configuration.Factory<Ticker>
SYSTEM_TICKER
private javax.cache.configuration.Factory<Ticker>
tickerFactory
private @Nullable javax.cache.configuration.Factory<Weigher<K,V>>
weigherFactory
-
Constructor Summary
Constructors Constructor Description CaffeineConfiguration()
CaffeineConfiguration(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
SeeMutableConfiguration.addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>)
.boolean
equals(java.lang.Object o)
java.lang.Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>>
getCacheEntryListenerConfigurations()
javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>>
getCacheLoaderFactory()
@Nullable javax.cache.integration.CacheWriter<K,V>
getCacheWriter()
javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>>
getCacheWriterFactory()
javax.cache.configuration.Factory<Copier>
getCopierFactory()
Returns theFactory
for theCopier
to be used for the cache.javax.cache.configuration.Factory<java.util.concurrent.Executor>
getExecutorFactory()
Returns theFactory
for theExecutor
to be used for the cache.java.util.OptionalLong
getExpireAfterAccess()
Returns the expire after access in nanoseconds.java.util.OptionalLong
getExpireAfterWrite()
Returns the expire after write in nanoseconds.java.util.Optional<javax.cache.configuration.Factory<Expiry<K,V>>>
getExpiryFactory()
Returns theFactory
for theExpiry
to be used for the cache.javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>
getExpiryPolicyFactory()
java.lang.Class<K>
getKeyType()
java.util.OptionalLong
getMaximumSize()
Returns the maximum size to be used for the cache.java.util.OptionalLong
getMaximumWeight()
Returns the maximum weight to be used for the cache.java.util.OptionalLong
getRefreshAfterWrite()
Returns the refresh after write in nanoseconds.javax.cache.configuration.Factory<Scheduler>
getSchedulerFactory()
Returns theFactory
for theScheduler
to be used for the cache.javax.cache.configuration.Factory<Ticker>
getTickerFactory()
Returns theFactory
for theTicker
to be used for the cache.java.lang.Class<V>
getValueType()
java.util.Optional<javax.cache.configuration.Factory<Weigher<K,V>>>
getWeigherFactory()
Returns theFactory
for theWeigher
to be used for the cache.boolean
hasCacheWriter()
int
hashCode()
boolean
isManagementEnabled()
SeeMutableConfiguration.isManagementEnabled
.boolean
isNativeStatisticsEnabled()
Checks whether native statistics collection is enabled in this cache.boolean
isReadThrough()
boolean
isStatisticsEnabled()
boolean
isStoreByValue()
boolean
isWriteThrough()
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<java.util.concurrent.Executor> factory)
Set theFactory
for theExecutor
.void
setExpireAfterAccess(java.util.OptionalLong expireAfterAccessNanos)
Set the expire after write in nanoseconds.void
setExpireAfterWrite(java.util.OptionalLong expireAfterWriteNanos)
Set the expire after write in nanoseconds.void
setExpiryFactory(java.util.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(java.util.OptionalLong maximumSize)
Set the maximum size.void
setMaximumWeight(java.util.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(java.util.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
setTypes(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
SeeMutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>)
.void
setWeigherFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Weigher<K,V>>> factory)
Set theFactory
for theWeigher
.void
setWriteThrough(boolean isWriteThrough)
SeeMutableConfiguration.setWriteThrough(boolean)
.
-
-
-
Field Detail
-
DISABLED_SCHEDULER
private static final javax.cache.configuration.Factory<Scheduler> DISABLED_SCHEDULER
-
JAVA_COPIER
private static final javax.cache.configuration.Factory<Copier> JAVA_COPIER
-
COMMON_POOL
private static final javax.cache.configuration.Factory<java.util.concurrent.Executor> COMMON_POOL
-
SYSTEM_TICKER
private static final javax.cache.configuration.Factory<Ticker> SYSTEM_TICKER
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
schedulerFactory
private javax.cache.configuration.Factory<Scheduler> schedulerFactory
-
executorFactory
private javax.cache.configuration.Factory<java.util.concurrent.Executor> executorFactory
-
copierFactory
private javax.cache.configuration.Factory<Copier> copierFactory
-
tickerFactory
private javax.cache.configuration.Factory<Ticker> tickerFactory
-
refreshAfterWriteNanos
private @Nullable java.lang.Long refreshAfterWriteNanos
-
expireAfterAccessNanos
private @Nullable java.lang.Long expireAfterAccessNanos
-
expireAfterWriteNanos
private @Nullable java.lang.Long expireAfterWriteNanos
-
maximumWeight
private @Nullable java.lang.Long maximumWeight
-
maximumSize
private @Nullable java.lang.Long maximumSize
-
nativeStatistics
private boolean nativeStatistics
-
-
Method Detail
-
getKeyType
public java.lang.Class<K> getKeyType()
-
getValueType
public java.lang.Class<V> getValueType()
-
setTypes
public void setTypes(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
SeeMutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>)
.
-
getCacheEntryListenerConfigurations
public java.lang.Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,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
public javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<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
public javax.cache.configuration.Factory<javax.cache.integration.CacheWriter<? super K,? super V>> getCacheWriterFactory()
-
getCacheWriter
public @Nullable javax.cache.integration.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
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
public javax.cache.configuration.Factory<Copier> getCopierFactory()
Returns theFactory
for theCopier
to be used for the cache.- Returns:
- the
Factory
for theCopier
-
setCopierFactory
public void setCopierFactory(javax.cache.configuration.Factory<Copier> factory)
Set theFactory
for theCopier
.- Parameters:
factory
- theCopier
Factory
-
getSchedulerFactory
public javax.cache.configuration.Factory<Scheduler> getSchedulerFactory()
Returns theFactory
for theScheduler
to be used for the cache.- Returns:
- the
Factory
for theScheduler
-
setSchedulerFactory
public void setSchedulerFactory(javax.cache.configuration.Factory<Scheduler> factory)
Set theFactory
for theScheduler
.- Parameters:
factory
- theScheduler
Factory
-
getTickerFactory
public javax.cache.configuration.Factory<Ticker> getTickerFactory()
Returns theFactory
for theTicker
to be used for the cache.- Returns:
- the
Factory
for theTicker
-
setTickerFactory
public void setTickerFactory(javax.cache.configuration.Factory<Ticker> factory)
Set theFactory
for theTicker
.- Parameters:
factory
- theTicker
Factory
-
getExecutorFactory
public javax.cache.configuration.Factory<java.util.concurrent.Executor> getExecutorFactory()
Returns theFactory
for theExecutor
to be used for the cache.- Returns:
- the
Factory
for theExecutor
-
setExecutorFactory
public void setExecutorFactory(javax.cache.configuration.Factory<java.util.concurrent.Executor> factory)
Set theFactory
for theExecutor
.- Parameters:
factory
- theExecutor
Factory
-
getRefreshAfterWrite
public java.util.OptionalLong getRefreshAfterWrite()
Returns the refresh after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setRefreshAfterWrite
public void setRefreshAfterWrite(java.util.OptionalLong refreshAfterWriteNanos)
Set the refresh after write in nanoseconds.- Parameters:
refreshAfterWriteNanos
- the duration in nanoseconds
-
getExpireAfterWrite
public java.util.OptionalLong getExpireAfterWrite()
Returns the expire after write in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterWrite
public void setExpireAfterWrite(java.util.OptionalLong expireAfterWriteNanos)
Set the expire after write in nanoseconds.- Parameters:
expireAfterWriteNanos
- the duration in nanoseconds
-
getExpireAfterAccess
public java.util.OptionalLong getExpireAfterAccess()
Returns the expire after access in nanoseconds.- Returns:
- the duration in nanoseconds
-
setExpireAfterAccess
public void setExpireAfterAccess(java.util.OptionalLong expireAfterAccessNanos)
Set the expire after write in nanoseconds.- Parameters:
expireAfterAccessNanos
- the duration in nanoseconds
-
getExpiryFactory
public java.util.Optional<javax.cache.configuration.Factory<Expiry<K,V>>> getExpiryFactory()
Returns theFactory
for theExpiry
to be used for the cache.- Returns:
- the
Factory
for theExpiry
-
setExpiryFactory
public void setExpiryFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Expiry<K,V>>> factory)
Set theFactory
for theExpiry
.- Parameters:
factory
- theExpiry
Factory
-
setMaximumSize
public void setMaximumSize(java.util.OptionalLong maximumSize)
Set the maximum size.- Parameters:
maximumSize
- the maximum size
-
getMaximumSize
public java.util.OptionalLong getMaximumSize()
Returns the maximum size to be used for the cache.- Returns:
- the maximum size
-
setMaximumWeight
public void setMaximumWeight(java.util.OptionalLong maximumWeight)
Set the maximum weight.- Parameters:
maximumWeight
- the maximum weighted size
-
getMaximumWeight
public java.util.OptionalLong getMaximumWeight()
Returns the maximum weight to be used for the cache.- Returns:
- the maximum weight
-
getWeigherFactory
public java.util.Optional<javax.cache.configuration.Factory<Weigher<K,V>>> getWeigherFactory()
Returns theFactory
for theWeigher
to be used for the cache.- Returns:
- the
Factory
for theWeigher
-
setWeigherFactory
public void setWeigherFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Weigher<K,V>>> factory)
Set theFactory
for theWeigher
.- Parameters:
factory
- theWeigher
Factory
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-