Interface CacheConfiguration<K,​V>

Type Parameters:
K - the type of key
V - the type of value
All Superinterfaces:
javax.cache.configuration.CompleteConfiguration<K,​V>, javax.cache.configuration.Configuration<K,​V>, Serializable
All Known Implementing Classes:
AbstractCacheConfig, CacheConfig

public interface CacheConfiguration<K,​V>
extends javax.cache.configuration.CompleteConfiguration<K,​V>
Mutable extension to CompleteConfiguration
  • Method Details

    • setTypes

      CacheConfiguration<K,​V> setTypes​(Class<K> keyType, Class<V> valueType)
      Sets the expected type of keys and values for a Cache configured with this Configuration. Setting both to Object.class means type-safety checks are not required.

      This is used by CacheManager to ensure that the key and value types are the same as those configured for the Cache prior to returning a requested cache from this method.

      Implementations may further perform type checking on mutative cache operations and throw a ClassCastException if these checks fail.

      Parameters:
      keyType - the expected key type
      valueType - the expected value type
      Returns:
      the CacheConfiguration to permit fluent-style method calls
      Throws:
      NullPointerException - should the key or value type be null
      See Also:
      CacheManager.getCache(String, Class, Class)
    • addCacheEntryListenerConfiguration

      CacheConfiguration<K,​V> addCacheEntryListenerConfiguration​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cacheEntryListenerConfiguration)
      Add a configuration for a CacheEntryListener.
      Parameters:
      cacheEntryListenerConfiguration - the CacheEntryListenerConfiguration
      Returns:
      the CacheConfiguration to permit fluent-style method calls
      Throws:
      IllegalArgumentException - if the same CacheEntryListenerConfiguration is used more than once
    • removeCacheEntryListenerConfiguration

      CacheConfiguration<K,​V> removeCacheEntryListenerConfiguration​(javax.cache.configuration.CacheEntryListenerConfiguration<K,​V> cacheEntryListenerConfiguration)
      Remove a configuration for a CacheEntryListener.
      Parameters:
      cacheEntryListenerConfiguration - the CacheEntryListenerConfiguration to remove
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setCacheLoaderFactory

      CacheConfiguration<K,​V> setCacheLoaderFactory​(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheLoader<K,​V>> factory)
      Set the CacheLoader factory.
      Parameters:
      factory - the CacheLoader Factory
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setCacheWriterFactory

      CacheConfiguration<K,​V> setCacheWriterFactory​(javax.cache.configuration.Factory<? extends javax.cache.integration.CacheWriter<? super K,​? super V>> factory)
      Set the CacheWriter factory.
      Parameters:
      factory - the CacheWriter Factory
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setExpiryPolicyFactory

      CacheConfiguration<K,​V> setExpiryPolicyFactory​(javax.cache.configuration.Factory<? extends javax.cache.expiry.ExpiryPolicy> factory)
      Set the Factory for the ExpiryPolicy. If null is specified the default ExpiryPolicy is used.
      Parameters:
      factory - the ExpiryPolicy Factory
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setReadThrough

      CacheConfiguration<K,​V> setReadThrough​(boolean isReadThrough)
      Set if read-through caching should be used.

      It is an invalid configuration to set this to true without specifying a CacheLoader Factory.

      Parameters:
      isReadThrough - true if read-through is required, false otherwise
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setWriteThrough

      CacheConfiguration<K,​V> setWriteThrough​(boolean isWriteThrough)
      Set if write-through caching should be used.

      It is an invalid configuration to set this to true without specifying a CacheWriter Factory.

      Parameters:
      isWriteThrough - true if write-through is required, false otherwise
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setStoreByValue

      CacheConfiguration<K,​V> setStoreByValue​(boolean isStoreByValue)
      Set if a configured cache should use store-by-value or store-by-reference semantics.
      Parameters:
      isStoreByValue - true if store-by-value is required, false for store-by-reference
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setStatisticsEnabled

      CacheConfiguration<K,​V> setStatisticsEnabled​(boolean enabled)
      Sets whether statistics gathering is enabled on a cache.

      Statistics may be enabled or disabled at runtime via CacheManager.enableStatistics(String, boolean).

      Parameters:
      enabled - true to enable statistics, false to disable
      Returns:
      the CacheConfiguration to permit fluent-style method calls
    • setManagementEnabled

      CacheConfiguration<K,​V> setManagementEnabled​(boolean enabled)
      Sets whether management is enabled on a cache.

      Management may be enabled or disabled at runtime via CacheManager.enableManagement(String, boolean).

      Parameters:
      enabled - true to enable statistics, false to disable
      Returns:
      the CacheConfiguration to permit fluent-style method calls