public class CacheConfiguration
extends java.lang.Object
A base configuration class for configuring caches.
Modifier and Type | Field and Description |
---|---|
protected java.nio.charset.Charset |
charset |
static boolean |
DEFAULT_RECORD_STATS
The default record stats value.
|
static boolean |
DEFAULT_TESTMODE
The default test mode value.
|
static java.lang.String |
PREFIX
The prefix for cache configuration.
|
Constructor and Description |
---|
CacheConfiguration(java.lang.String cacheName,
io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
Creates a new cache with the given name.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCacheName() |
java.nio.charset.Charset |
getCharset() |
java.util.Optional<java.time.Duration> |
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.
|
java.util.Optional<java.time.Duration> |
getExpireAfterWrite() |
java.util.OptionalInt |
getInitialCapacity() |
java.util.OptionalLong |
getMaximumSize() |
java.util.OptionalLong |
getMaximumWeight() |
boolean |
isRecordStats()
Some caches support recording statistics.
|
boolean |
isTestMode()
Some caches have a test mode.
|
void |
setCharset(java.nio.charset.Charset charset) |
void |
setExpireAfterAccess(java.time.Duration expireAfterAccess) |
void |
setExpireAfterWrite(java.time.Duration expireAfterWrite) |
void |
setInitialCapacity(java.lang.Integer initialCapacity) |
void |
setMaximumSize(java.lang.Long maximumSize) |
void |
setMaximumWeight(java.lang.Long maximumWeight) |
void |
setRecordStats(boolean recordStats)
Set whether record stats is enabled.
|
void |
setTestMode(boolean testMode)
Set whether test mode is enabled.
|
public static final java.lang.String PREFIX
public static final boolean DEFAULT_RECORD_STATS
public static final boolean DEFAULT_TESTMODE
protected java.nio.charset.Charset charset
public CacheConfiguration(@Parameter java.lang.String cacheName, io.micronaut.runtime.ApplicationConfiguration applicationConfiguration)
cacheName
- Name or key of the cacheapplicationConfiguration
- The common application configurationpublic java.lang.String getCacheName()
public java.util.OptionalInt getInitialCapacity()
public java.util.OptionalLong getMaximumSize()
public java.util.OptionalLong getMaximumWeight()
public java.util.Optional<java.time.Duration> getExpireAfterWrite()
public java.util.Optional<java.time.Duration> getExpireAfterAccess()
Duration
public boolean isRecordStats()
public java.nio.charset.Charset getCharset()
public void setInitialCapacity(java.lang.Integer initialCapacity)
initialCapacity
- The initial cache capacity.public void setMaximumSize(java.lang.Long maximumSize)
maximumSize
- Specifies the maximum number of entries the cache may containpublic void setMaximumWeight(java.lang.Long maximumWeight)
maximumWeight
- Specifies the maximum weight of entriespublic void setExpireAfterWrite(java.time.Duration expireAfterWrite)
expireAfterWrite
- The cache expiration duration after writing into it.public void setExpireAfterAccess(java.time.Duration expireAfterAccess)
expireAfterAccess
- The cache expiration duration after accessing itpublic void setRecordStats(boolean recordStats)
recordStats
- True if record status is enabledpublic void setCharset(java.nio.charset.Charset charset)
charset
- The charset used to serialize and deserialize valuespublic boolean isTestMode()
public void setTestMode(boolean testMode)
testMode
- True if test mode is eanbled