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 Details

    • 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<Executor> COMMON_POOL
    • SYSTEM_TICKER

      private static final javax.cache.configuration.Factory<Ticker> SYSTEM_TICKER
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • delegate

      private final javax.cache.configuration.MutableConfiguration<K,V> delegate
    • weigherFactory

      private @Nullable javax.cache.configuration.Factory<Weigher<K,V>> weigherFactory
    • expiryFactory

      private @Nullable javax.cache.configuration.Factory<Expiry<K,V>> expiryFactory
    • schedulerFactory

      private javax.cache.configuration.Factory<Scheduler> schedulerFactory
    • executorFactory

      private javax.cache.configuration.Factory<Executor> executorFactory
    • copierFactory

      private javax.cache.configuration.Factory<Copier> copierFactory
    • tickerFactory

      private javax.cache.configuration.Factory<Ticker> tickerFactory
    • refreshAfterWriteNanos

      private @Nullable Long refreshAfterWriteNanos
    • expireAfterAccessNanos

      private @Nullable Long expireAfterAccessNanos
    • expireAfterWriteNanos

      private @Nullable Long expireAfterWriteNanos
    • maximumWeight

      private @Nullable Long maximumWeight
    • maximumSize

      private @Nullable Long maximumSize
    • nativeStatistics

      private boolean nativeStatistics
  • Constructor Details

    • CaffeineConfiguration

      public CaffeineConfiguration()
    • CaffeineConfiguration

      public CaffeineConfiguration(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
  • Method Details

    • getKeyType

      public Class<K> getKeyType()
      Specified by:
      getKeyType in interface javax.cache.configuration.Configuration<K,V>
    • getValueType

      public Class<V> getValueType()
      Specified by:
      getValueType in interface javax.cache.configuration.Configuration<K,V>
    • setTypes

      public void setTypes(Class<K> keyType, Class<V> valueType)
      See MutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>).
    • getCacheEntryListenerConfigurations

      public Iterable<javax.cache.configuration.CacheEntryListenerConfiguration<K,V>> getCacheEntryListenerConfigurations()
      Specified by:
      getCacheEntryListenerConfigurations in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • addCacheEntryListenerConfiguration

      public void addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
      See MutableConfiguration.addCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>).
    • removeCacheEntryListenerConfiguration

      public void removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K,V> cacheEntryListenerConfiguration)
      See MutableConfiguration.removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>).
    • getCacheLoaderFactory

      public javax.cache.configuration.Factory<javax.cache.integration.CacheLoader<K,V>> getCacheLoaderFactory()
      Specified by:
      getCacheLoaderFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setCacheLoaderFactory

      public void setCacheLoaderFactory(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,V>> factory)
      See MutableConfiguration.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()
      Specified by:
      getCacheWriterFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • 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)
      See MutableConfiguration.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()
      Specified by:
      getExpiryPolicyFactory in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setExpiryPolicyFactory

      public void setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory)
      See MutableConfiguration.setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy>).
    • isReadThrough

      public boolean isReadThrough()
      Specified by:
      isReadThrough in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setReadThrough

      public void setReadThrough(boolean isReadThrough)
      See MutableConfiguration.setReadThrough(boolean).
    • isWriteThrough

      public boolean isWriteThrough()
      Specified by:
      isWriteThrough in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setWriteThrough

      public void setWriteThrough(boolean isWriteThrough)
      See MutableConfiguration.setWriteThrough(boolean).
    • isStoreByValue

      public boolean isStoreByValue()
      Specified by:
      isStoreByValue in interface javax.cache.configuration.Configuration<K,V>
    • setStoreByValue

      public void setStoreByValue(boolean isStoreByValue)
      See MutableConfiguration.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()
      Specified by:
      isStatisticsEnabled in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setStatisticsEnabled

      public void setStatisticsEnabled(boolean enabled)
      See MutableConfiguration.setStatisticsEnabled(boolean).
    • isManagementEnabled

      public boolean isManagementEnabled()
      See MutableConfiguration.isManagementEnabled.
      Specified by:
      isManagementEnabled in interface javax.cache.configuration.CompleteConfiguration<K,V>
    • setManagementEnabled

      public void setManagementEnabled(boolean enabled)
      See MutableConfiguration.setManagementEnabled(boolean).
    • getCopierFactory

      public javax.cache.configuration.Factory<Copier> getCopierFactory()
      Returns the Factory for the Copier to be used for the cache.
      Returns:
      the Factory for the Copier
    • setCopierFactory

      public void setCopierFactory(javax.cache.configuration.Factory<Copier> factory)
      Set the Factory for the Copier.
      Parameters:
      factory - the Copier Factory
    • getSchedulerFactory

      public javax.cache.configuration.Factory<Scheduler> getSchedulerFactory()
      Returns the Factory for the Scheduler to be used for the cache.
      Returns:
      the Factory for the Scheduler
    • setSchedulerFactory

      public void setSchedulerFactory(javax.cache.configuration.Factory<Scheduler> factory)
      Set the Factory for the Scheduler.
      Parameters:
      factory - the Scheduler Factory
    • getTickerFactory

      public javax.cache.configuration.Factory<Ticker> getTickerFactory()
      Returns the Factory for the Ticker to be used for the cache.
      Returns:
      the Factory for the Ticker
    • setTickerFactory

      public void setTickerFactory(javax.cache.configuration.Factory<Ticker> factory)
      Set the Factory for the Ticker.
      Parameters:
      factory - the Ticker Factory
    • getExecutorFactory

      public javax.cache.configuration.Factory<Executor> getExecutorFactory()
      Returns the Factory for the Executor to be used for the cache.
      Returns:
      the Factory for the Executor
    • setExecutorFactory

      public void setExecutorFactory(javax.cache.configuration.Factory<Executor> factory)
      Set the Factory for the Executor.
      Parameters:
      factory - the Executor Factory
    • getRefreshAfterWrite

      public OptionalLong getRefreshAfterWrite()
      Returns the refresh after write in nanoseconds.
      Returns:
      the duration in nanoseconds
    • setRefreshAfterWrite

      public void setRefreshAfterWrite(OptionalLong refreshAfterWriteNanos)
      Set the refresh after write in nanoseconds.
      Parameters:
      refreshAfterWriteNanos - the duration in nanoseconds
    • getExpireAfterWrite

      public OptionalLong getExpireAfterWrite()
      Returns the expire after write in nanoseconds.
      Returns:
      the duration in nanoseconds
    • setExpireAfterWrite

      public void setExpireAfterWrite(OptionalLong expireAfterWriteNanos)
      Set the expire after write in nanoseconds.
      Parameters:
      expireAfterWriteNanos - the duration in nanoseconds
    • getExpireAfterAccess

      public OptionalLong getExpireAfterAccess()
      Returns the expire after access in nanoseconds.
      Returns:
      the duration in nanoseconds
    • setExpireAfterAccess

      public void setExpireAfterAccess(OptionalLong expireAfterAccessNanos)
      Set the expire after write in nanoseconds.
      Parameters:
      expireAfterAccessNanos - the duration in nanoseconds
    • getExpiryFactory

      public Optional<javax.cache.configuration.Factory<Expiry<K,V>>> getExpiryFactory()
      Returns the Factory for the Expiry to be used for the cache.
      Returns:
      the Factory for the Expiry
    • setExpiryFactory

      public void setExpiryFactory(Optional<javax.cache.configuration.Factory<? extends Expiry<K,V>>> factory)
      Set the Factory for the Expiry.
      Parameters:
      factory - the Expiry Factory
    • setMaximumSize

      public void setMaximumSize(OptionalLong maximumSize)
      Set the maximum size.
      Parameters:
      maximumSize - the maximum size
    • getMaximumSize

      public OptionalLong getMaximumSize()
      Returns the maximum size to be used for the cache.
      Returns:
      the maximum size
    • setMaximumWeight

      public void setMaximumWeight(OptionalLong maximumWeight)
      Set the maximum weight.
      Parameters:
      maximumWeight - the maximum weighted size
    • getMaximumWeight

      public OptionalLong getMaximumWeight()
      Returns the maximum weight to be used for the cache.
      Returns:
      the maximum weight
    • getWeigherFactory

      public Optional<javax.cache.configuration.Factory<Weigher<K,V>>> getWeigherFactory()
      Returns the Factory for the Weigher to be used for the cache.
      Returns:
      the Factory for the Weigher
    • setWeigherFactory

      public void setWeigherFactory(Optional<javax.cache.configuration.Factory<? extends Weigher<K,V>>> factory)
      Set the Factory for the Weigher.
      Parameters:
      factory - the Weigher Factory
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object