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