Package io.micronaut.cache
Class CacheConfiguration
java.lang.Object
io.micronaut.cache.CacheConfiguration
- Direct Known Subclasses:
CaffeineCacheConfiguration
,DiscoveryClientCacheConfiguration
A base configuration class for configuring caches.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCacheConfiguration
(String cacheName, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Creates a new cache with the given name. -
Method Summary
Modifier and TypeMethodDescriptionSpecifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.boolean
Some caches support recording statistics.boolean
Some caches have a test mode.void
setCharset
(Charset charset) void
setExpireAfterAccess
(Duration expireAfterAccess) void
setExpireAfterWrite
(Duration expireAfterWrite) void
setInitialCapacity
(Integer initialCapacity) void
setMaximumSize
(Long maximumSize) void
setMaximumWeight
(Long maximumWeight) void
setRecordStats
(boolean recordStats) Set whether record stats is enabled.void
setTestMode
(boolean testMode) Set whether test mode is enabled.
-
Field Details
-
PREFIX
The prefix for cache configuration.- See Also:
-
DEFAULT_RECORD_STATS
public static final boolean DEFAULT_RECORD_STATSThe default record stats value.- See Also:
-
DEFAULT_TESTMODE
public static final boolean DEFAULT_TESTMODEThe default test mode value.- See Also:
-
charset
-
-
Constructor Details
-
CacheConfiguration
public CacheConfiguration(@Parameter String cacheName, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration) Creates a new cache with the given name.- Parameters:
cacheName
- Name or key of the cacheapplicationConfiguration
- The common application configuration
-
-
Method Details
-
getCacheName
- Returns:
- The name of the cache
-
getInitialCapacity
- Returns:
- The initial capacity of the cache
-
getMaximumSize
- Returns:
- The maximum size of the cache
-
getMaximumWeight
- Returns:
- The maximum weight of cache entries
-
getExpireAfterWrite
- Returns:
- The expiry to use after the value is written
-
getExpireAfterAccess
Specifies that each entry should be automatically removed from the cache once a fixed duration has elapsed after the entry's creation, the most recent replacement of its value, or its last read.- Returns:
- The
Duration
-
isRecordStats
public boolean isRecordStats()Some caches support recording statistics. For example to record hit and miss ratio's fine tune the cache characteristics.- Returns:
- True if record stats is enabled
-
getCharset
- Returns:
- The charset used to serialize and deserialize values
-
setInitialCapacity
- Parameters:
initialCapacity
- The initial cache capacity.
-
setMaximumSize
- Parameters:
maximumSize
- Specifies the maximum number of entries the cache may contain
-
setMaximumWeight
- Parameters:
maximumWeight
- Specifies the maximum weight of entries
-
setExpireAfterWrite
- Parameters:
expireAfterWrite
- The cache expiration duration after writing into it.
-
setExpireAfterAccess
- Parameters:
expireAfterAccess
- The cache expiration duration after accessing it
-
setRecordStats
public void setRecordStats(boolean recordStats) Set whether record stats is enabled. Default value (false).- Parameters:
recordStats
- True if record status is enabled
-
setCharset
- Parameters:
charset
- The charset used to serialize and deserialize values
-
isTestMode
public boolean isTestMode()Some caches have a test mode. For example to to enable the eager execution of cleanup operations making it easier to test.- Returns:
- True if it test mode is enabled
-
setTestMode
public void setTestMode(boolean testMode) Set whether test mode is enabled. Default value (false).- Parameters:
testMode
- True if test mode is eanbled
-