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
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
-
-
Field Summary
Fields Modifier and Type Field Description private static javax.cache.configuration.Factory<java.util.concurrent.Executor>COMMON_POOLprivate javax.cache.configuration.Factory<Copier>copierFactoryprivate javax.cache.configuration.MutableConfiguration<K,V>delegateprivate static javax.cache.configuration.Factory<Scheduler>DISABLED_SCHEDULERprivate javax.cache.configuration.Factory<java.util.concurrent.Executor>executorFactoryprivate @Nullable java.lang.LongexpireAfterAccessNanosprivate @Nullable java.lang.LongexpireAfterWriteNanosprivate @Nullable javax.cache.configuration.Factory<Expiry<K,V>>expiryFactoryprivate static javax.cache.configuration.Factory<Copier>JAVA_COPIERprivate @Nullable java.lang.LongmaximumSizeprivate @Nullable java.lang.LongmaximumWeightprivate booleannativeStatisticsprivate @Nullable java.lang.LongrefreshAfterWriteNanosprivate javax.cache.configuration.Factory<Scheduler>schedulerFactoryprivate static longserialVersionUIDprivate static javax.cache.configuration.Factory<Ticker>SYSTEM_TICKERprivate javax.cache.configuration.Factory<Ticker>tickerFactoryprivate @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 voidaddCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)SeeMutableConfiguration.addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>).booleanequals(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 theFactoryfor theCopierto be used for the cache.javax.cache.configuration.Factory<java.util.concurrent.Executor>getExecutorFactory()Returns theFactoryfor theExecutorto be used for the cache.java.util.OptionalLonggetExpireAfterAccess()Returns the expire after access in nanoseconds.java.util.OptionalLonggetExpireAfterWrite()Returns the expire after write in nanoseconds.java.util.Optional<javax.cache.configuration.Factory<Expiry<K,V>>>getExpiryFactory()Returns theFactoryfor theExpiryto be used for the cache.javax.cache.configuration.Factory<javax.cache.expiry.ExpiryPolicy>getExpiryPolicyFactory()java.lang.Class<K>getKeyType()java.util.OptionalLonggetMaximumSize()Returns the maximum size to be used for the cache.java.util.OptionalLonggetMaximumWeight()Returns the maximum weight to be used for the cache.java.util.OptionalLonggetRefreshAfterWrite()Returns the refresh after write in nanoseconds.javax.cache.configuration.Factory<Scheduler>getSchedulerFactory()Returns theFactoryfor theSchedulerto be used for the cache.javax.cache.configuration.Factory<Ticker>getTickerFactory()Returns theFactoryfor theTickerto be used for the cache.java.lang.Class<V>getValueType()java.util.Optional<javax.cache.configuration.Factory<Weigher<K,V>>>getWeigherFactory()Returns theFactoryfor theWeigherto be used for the cache.booleanhasCacheWriter()inthashCode()booleanisManagementEnabled()SeeMutableConfiguration.isManagementEnabled.booleanisNativeStatisticsEnabled()Checks whether native statistics collection is enabled in this cache.booleanisReadThrough()booleanisStatisticsEnabled()booleanisStoreByValue()booleanisWriteThrough()voidremoveCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)SeeMutableConfiguration.removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>).voidsetCacheLoaderFactory(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>>).voidsetCacheWriterFactory(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>>).voidsetCopierFactory(javax.cache.configuration.Factory<Copier> factory)Set theFactoryfor theCopier.voidsetExecutorFactory(javax.cache.configuration.Factory<java.util.concurrent.Executor> factory)Set theFactoryfor theExecutor.voidsetExpireAfterAccess(java.util.OptionalLong expireAfterAccessNanos)Set the expire after write in nanoseconds.voidsetExpireAfterWrite(java.util.OptionalLong expireAfterWriteNanos)Set the expire after write in nanoseconds.voidsetExpiryFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Expiry<K,V>>> factory)Set theFactoryfor theExpiry.voidsetExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory)SeeMutableConfiguration.setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy>).voidsetManagementEnabled(boolean enabled)SeeMutableConfiguration.setManagementEnabled(boolean).voidsetMaximumSize(java.util.OptionalLong maximumSize)Set the maximum size.voidsetMaximumWeight(java.util.OptionalLong maximumWeight)Set the maximum weight.voidsetNativeStatisticsEnabled(boolean enabled)Sets whether native statistics gathering is enabled on a cache.voidsetReadThrough(boolean isReadThrough)SeeMutableConfiguration.setReadThrough(boolean).voidsetRefreshAfterWrite(java.util.OptionalLong refreshAfterWriteNanos)Set the refresh after write in nanoseconds.voidsetSchedulerFactory(javax.cache.configuration.Factory<Scheduler> factory)Set theFactoryfor theScheduler.voidsetStatisticsEnabled(boolean enabled)SeeMutableConfiguration.setStatisticsEnabled(boolean).voidsetStoreByValue(boolean isStoreByValue)SeeMutableConfiguration.setStoreByValue(boolean).voidsetTickerFactory(javax.cache.configuration.Factory<Ticker> factory)Set theFactoryfor theTicker.voidsetTypes(java.lang.Class<K> keyType, java.lang.Class<V> valueType)SeeMutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>).voidsetWeigherFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Weigher<K,V>>> factory)Set theFactoryfor theWeigher.voidsetWriteThrough(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 theFactoryfor theCopierto be used for the cache.- Returns:
- the
Factoryfor theCopier
-
setCopierFactory
public void setCopierFactory(javax.cache.configuration.Factory<Copier> factory)
Set theFactoryfor theCopier.- Parameters:
factory- theCopierFactory
-
getSchedulerFactory
public javax.cache.configuration.Factory<Scheduler> getSchedulerFactory()
Returns theFactoryfor theSchedulerto be used for the cache.- Returns:
- the
Factoryfor theScheduler
-
setSchedulerFactory
public void setSchedulerFactory(javax.cache.configuration.Factory<Scheduler> factory)
Set theFactoryfor theScheduler.- Parameters:
factory- theSchedulerFactory
-
getTickerFactory
public javax.cache.configuration.Factory<Ticker> getTickerFactory()
Returns theFactoryfor theTickerto be used for the cache.- Returns:
- the
Factoryfor theTicker
-
setTickerFactory
public void setTickerFactory(javax.cache.configuration.Factory<Ticker> factory)
Set theFactoryfor theTicker.- Parameters:
factory- theTickerFactory
-
getExecutorFactory
public javax.cache.configuration.Factory<java.util.concurrent.Executor> getExecutorFactory()
Returns theFactoryfor theExecutorto be used for the cache.- Returns:
- the
Factoryfor theExecutor
-
setExecutorFactory
public void setExecutorFactory(javax.cache.configuration.Factory<java.util.concurrent.Executor> factory)
Set theFactoryfor theExecutor.- Parameters:
factory- theExecutorFactory
-
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 theFactoryfor theExpiryto be used for the cache.- Returns:
- the
Factoryfor theExpiry
-
setExpiryFactory
public void setExpiryFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Expiry<K,V>>> factory)
Set theFactoryfor theExpiry.- Parameters:
factory- theExpiryFactory
-
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 theFactoryfor theWeigherto be used for the cache.- Returns:
- the
Factoryfor theWeigher
-
setWeigherFactory
public void setWeigherFactory(java.util.Optional<javax.cache.configuration.Factory<? extends Weigher<K,V>>> factory)
Set theFactoryfor theWeigher.- Parameters:
factory- theWeigherFactory
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-