Class CoherenceCacheConfiguration
java.lang.Object
com.oracle.coherence.spring.cache.CoherenceCacheConfiguration
Defines additional configuration properties for the
CoherenceCache. Can also serve as default cache configuration
via CoherenceCacheManager.- Since:
- 3.0
- Author:
- Gunnar Hillert
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor.CoherenceCacheConfiguration(Duration timeToLive) Initialize the cache configuration properties. -
Method Summary
Modifier and TypeMethodDescriptiongetCacheName(String name) Return the full cache name for the provided base cache name.The String to prepend cache names with.longReturns the number of milliseconds to continue trying to obtain a lock.Returns the expiration time for cache entries.booleanIf returning true, this property will lock the entire cache.booleanThis property is false by default.booleanIf true, cache entries will be locked for concurrency control.voidsetCacheNamePrefix(String cacheNamePrefix) Set the String to prepend the cache name with.voidsetLockEntireCache(boolean lockEntireCache) If setting to true, this property will lock the entire cache.voidsetLockTimeout(long lockTimeout) Will set the lock timeout in milliseconds.voidsetTimeToLive(Duration timeToLive) Sets the expiration time for cache entries.voidsetUseCacheNamePrefix(boolean useCacheNamePrefix) This property is false by default.voidsetUseLocks(boolean useLocks) If true, cache entries will be locked for concurrency control.
-
Constructor Details
-
CoherenceCacheConfiguration
public CoherenceCacheConfiguration()The default constructor. -
CoherenceCacheConfiguration
Initialize the cache configuration properties.- Parameters:
timeToLive- the expiration time for cache entries. Set this property toDuration.ZEROto control the expiration via the coherence-cache-config.xml file. A value of -1 milliseconds will cause cache entries not to expire.
-
-
Method Details
-
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
Sets the expiration time for cache entries. If not set, it will default toDuration.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 bygetCacheName(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 bygetCacheName(String).- Parameters:
useCacheNamePrefix- shall a cache name prefix be used? If not specified, this property defaults to false.
-
getCacheNamePrefix
The String to prepend cache names with. Empty by default. Will be ignored ifisUseCacheNamePrefix()is false.- Returns:
- the cache name prefix
-
setCacheNamePrefix
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
Return the full cache name for the provided base cache name. IfisUseCacheNamePrefix()returns true, the cache name will be prepended bygetCacheNamePrefix().- 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 inCoherenceCache.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 inCoherenceCache.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
-