Class CoherenceCacheConfiguration


  • public class CoherenceCacheConfiguration
    extends Object
    Defines additional configuration properties for the CoherenceCache. Can also serve as default cache configuration via CoherenceCacheManager.
    Since:
    3.0
    Author:
    Gunnar Hillert
    • Constructor Detail

      • CoherenceCacheConfiguration

        public CoherenceCacheConfiguration()
        The default constructor.
      • CoherenceCacheConfiguration

        public CoherenceCacheConfiguration​(Duration timeToLive)
        Initialize the cache configuration properties.
        Parameters:
        timeToLive - the expiration time for cache entries. Set this property to Duration.ZERO to control the expiration via the coherence-cache-config.xml file. A value of -1 milliseconds will cause cache entries not to expire.
    • Method Detail

      • getTimeToLive

        public Duration getTimeToLive()
        Returns the expiration time for cache entries. Should never be null. A value of zero milliseconds means that the cache's default expiration value shall be used, e.g. to control the expiration via the coherence-cache-config.xml file. A value of -1 milliseconds means that the cache value will never expire.
        Returns:
        the time-to-live (TTL) for cache entries. Defaults to Duration.ZERO.
      • setTimeToLive

        public void setTimeToLive​(Duration timeToLive)
        Sets the expiration time for cache entries. If not set, it will default to Duration.ZERO.
        Parameters:
        timeToLive - must neither be null nor smaller than -1 milliseconds.
      • isUseCacheNamePrefix

        public boolean isUseCacheNamePrefix()
        This property is false by default. If true, the cache name will be prefixed with the name specified by getCacheName(String).
        Returns:
        true if the getCacheNamePrefix() is to be used
      • setUseCacheNamePrefix

        public void setUseCacheNamePrefix​(boolean useCacheNamePrefix)
        This property is false by default. If set to true, the cache name will be prefixed with the name specified by getCacheName(String).
        Parameters:
        useCacheNamePrefix - shall a cache name prefix be used? If not specified, this property defaults to false.
      • getCacheNamePrefix

        public String getCacheNamePrefix()
        The String to prepend cache names with. Empty by default. Will be ignored if isUseCacheNamePrefix() is false.
        Returns:
        the cache name prefix
      • setCacheNamePrefix

        public void setCacheNamePrefix​(String cacheNamePrefix)
        Set the String to prepend the cache name with. If not set will default to an empty String.
        Parameters:
        cacheNamePrefix - the cache name prefix
      • getCacheName

        public String getCacheName​(String name)
        Return the full cache name for the provided base cache name. If isUseCacheNamePrefix() returns true, the cache name will be prepended by getCacheNamePrefix().
        Parameters:
        name - must not be null or empty
        Returns:
        the full cache name including prefix if enabled
      • isUseLocks

        public boolean isUseLocks()
        If true, cache entries will be locked for concurrency control. This property returns true by default. When using Coherence*Extend or gRPC, it is recommended to not use locking. This property is used by the value-loader in CoherenceCache.get(Object, Callable).
        Returns:
        if not set, will return true
      • setUseLocks

        public void setUseLocks​(boolean useLocks)
        If true, cache entries will be locked for concurrency control. This property is set to true by default. When using Coherence*Extend or gRPC, it is recommended to set this property to false.
        Parameters:
        useLocks - if not set will default to true
      • isLockEntireCache

        public boolean isLockEntireCache()
        If returning true, this property will lock the entire cache. This is usually not recommended.
        Returns:
        true if the entire cache shall be locked. This property is used by the value-loader in CoherenceCache.get(Object, Callable).
      • setLockEntireCache

        public void setLockEntireCache​(boolean lockEntireCache)
        If setting to true, this property will lock the entire cache. This is usually not recommended.
        Parameters:
        lockEntireCache - if not set defaults to false
      • getLockTimeout

        public long getLockTimeout()
        Returns the number of milliseconds to continue trying to obtain a lock. If zero is returned, the lock attempt will return immediately. A value of -1 means that the underlying locking operation will block indefinitely until the lock could be obtained. Defaults to 0. This property is used by the value-loader in CoherenceCache.get(Object, Callable).
        Returns:
        the lock timeout in milliseconds
      • setLockTimeout

        public void setLockTimeout​(long lockTimeout)
        Will set the lock timeout in milliseconds. If set to zero is returned, the lock attempt will return immediately. A value of -1 means that the underlying locking operation will block indefinitely until the lock could be obtained. If not set, this property defaults to 0.
        Parameters:
        lockTimeout - the lock timeout in milliseconds