Package javax.cache

Interface CacheConfiguration<K,​V>

  • Type Parameters:
    K - the type of keys maintained by this cache
    V - the type of cached values
    All Known Implementing Classes:
    CacheConfigurationImpl

    public interface CacheConfiguration<K,​V>
    A value object for cache configuration.

    A Cache may be constructed by CacheManager using a configuration instance.

    At runtime it is used by javax.cache to decide how to behave. For example the behaviour of put will vary depending on whether the cache is write-through.

    Finally, a cache makes its configuration visible via this interface.

    Only those configurations which can be changed at runtime (if supported by the underlying implementation) have setters in this interface. Those that can only be set prior to cache construction have setters in CacheBuilder.

    Since:
    1.0
    Author:
    Greg Luck, Yannis Cosmadopoulos
    • Method Detail

      • isReadThrough

        boolean isReadThrough()
        Whether the cache is a read-through cache. A CacheLoader should be configured for read through caches which is called by the cache for what without the loader would have been misses on Cache.get(Object) and {@link Cache#getAll(java.util.Set}.

        Default value is false.

        Returns:
        true if the cache is read-through
      • isWriteThrough

        boolean isWriteThrough()
        Whether the cache is a write-through cache. If so a CacheWriter should be configured.

        Default value is false.

        Returns:
        true if the cache is write-through
      • isStoreByValue

        boolean isStoreByValue()
        Whether storeByValue (true) or storeByReference (false). When true, both keys and values are stored by value.

        When false, both keys and values are stored by reference. Caches stored by reference are capable of mutation by any threads holding the reference. The effects are:

        • if the key is mutated, then the key may not be retrievable or removable
        • if the value is mutated, then all threads in the JVM can potentially observe those mutations, subject to the normal Java Memory Model rules.
        Storage by reference only applies to the local heap. If an entry is moved off heap it will need to be transformed into a representation. Any mutations that occur after transformation may not be reflected in the cache.

        The default value is true.

        When a cache is storeByValue, any mutation to the key or value does not affect the key of value stored in the cache.

        Returns:
        true if the cache is store by value
      • isStatisticsEnabled

        boolean isStatisticsEnabled()
        Checks whether statistics collection is enabled in this cache.

        The default value is false.

        Returns:
        true if statistics collection is enabled
      • setStatisticsEnabled

        void setStatisticsEnabled​(boolean enableStatistics)
        Sets whether statistics gathering is enabled on this cache. This may be changed at runtime.
        Parameters:
        enableStatistics - true to enable statistics, false to disable.
      • isTransactionEnabled

        boolean isTransactionEnabled()
        Checks whether transaction are enabled for this cache.

        Default value is false.

        Returns:
        true if transaction are enabled
      • getTransactionIsolationLevel

        IsolationLevel getTransactionIsolationLevel()
        Gets the transaction isolation level.
        Returns:
        the isolation level. IsolationLevel.NONE if this cache is not transactional.
      • getTransactionMode

        Mode getTransactionMode()
        Gets the transaction mode.
        Returns:
        the the mode of the cache. Mode.NONE if this cache is not transactional.