Class 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 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:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addCacheEntryListenerConfiguration​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cacheEntryListenerConfiguration)
      See MutableConfiguration.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 the Factory for the Copier to be used for the cache.
      javax.cache.configuration.Factory<java.util.concurrent.Executor> getExecutorFactory()
      Returns the Factory for the Executor 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 the Factory for the Expiry 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 the Factory for the Scheduler to be used for the cache.
      javax.cache.configuration.Factory<Ticker> getTickerFactory()
      Returns the Factory for the Ticker to be used for the cache.
      java.lang.Class<V> getValueType()  
      java.util.Optional<javax.cache.configuration.Factory<Weigher<K,​V>>> getWeigherFactory()
      Returns the Factory for the Weigher to be used for the cache.
      boolean hasCacheWriter()  
      int hashCode()  
      boolean isManagementEnabled()
      See MutableConfiguration.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)
      See MutableConfiguration.removeCacheEntryListenerConfiguration(javax.cache.configuration.CacheEntryListenerConfiguration<K, V>).
      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>>).
      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>>).
      void setCopierFactory​(javax.cache.configuration.Factory<Copier> factory)
      Set the Factory for the Copier.
      void setExecutorFactory​(javax.cache.configuration.Factory<java.util.concurrent.Executor> factory)
      Set the Factory for the Executor.
      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 the Factory for the Expiry.
      void setExpiryPolicyFactory​(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory)
      See MutableConfiguration.setExpiryPolicyFactory(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy>).
      void setManagementEnabled​(boolean enabled)
      See MutableConfiguration.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)
      See MutableConfiguration.setReadThrough(boolean).
      void setRefreshAfterWrite​(java.util.OptionalLong refreshAfterWriteNanos)
      Set the refresh after write in nanoseconds.
      void setSchedulerFactory​(javax.cache.configuration.Factory<Scheduler> factory)
      Set the Factory for the Scheduler.
      void setStatisticsEnabled​(boolean enabled)
      See MutableConfiguration.setStatisticsEnabled(boolean).
      void setStoreByValue​(boolean isStoreByValue)
      See MutableConfiguration.setStoreByValue(boolean).
      void setTickerFactory​(javax.cache.configuration.Factory<Ticker> factory)
      Set the Factory for the Ticker.
      void setTypes​(java.lang.Class<K> keyType, java.lang.Class<V> valueType)
      See MutableConfiguration.setTypes(java.lang.Class<K>, java.lang.Class<V>).
      void setWeigherFactory​(java.util.Optional<javax.cache.configuration.Factory<? extends Weigher<K,​V>>> factory)
      Set the Factory for the Weigher.
      void setWriteThrough​(boolean isWriteThrough)
      See MutableConfiguration.setWriteThrough(boolean).
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • 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
      • 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<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
    • Constructor Detail

      • CaffeineConfiguration

        public CaffeineConfiguration()
      • CaffeineConfiguration

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

      • getKeyType

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

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

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

        public java.lang.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<java.util.concurrent.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<java.util.concurrent.Executor> factory)
        Set the Factory for the Executor.
        Parameters:
        factory - the Executor 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 the Factory for the Expiry to be used for the cache.
        Returns:
        the Factory for the Expiry
      • setExpiryFactory

        public void setExpiryFactory​(java.util.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​(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 the Factory for the Weigher to be used for the cache.
        Returns:
        the Factory for the Weigher
      • setWeigherFactory

        public void setWeigherFactory​(java.util.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object