Class CacheProperties.CacheSpec
java.lang.Object
cloud.opencode.base.cache.spring.CacheProperties.CacheSpec
- Enclosing class:
CacheProperties
Cache specification for individual cache configuration
单个缓存配置的缓存规格
- Since:
- JDK 25, opencode-base-cache V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the concurrency level | 返回并发级别Returns the eviction policy name | 返回淘汰策略名称Returns the expire-after-access duration | 返回访问后过期时间Returns the expire-after-write duration | 返回写入后过期时间intReturns the initial capacity | 返回初始容量longReturns the maximum size | 返回最大大小longReturns the maximum weight | 返回最大权重Returns the refresh-after-write duration | 返回写入后刷新时间booleanReturns whether metrics export is enabled | 返回是否启用指标导出booleanReturns whether stats recording is enabled | 返回是否启用统计记录booleanReturns whether virtual threads are used | 返回是否使用虚拟线程voidsetConcurrencyLevel(int concurrencyLevel) Sets the concurrency level | 设置并发级别voidsetEvictionPolicy(String evictionPolicy) Sets the eviction policy name | 设置淘汰策略名称voidsetExpireAfterAccess(Duration expireAfterAccess) Sets the expire-after-access duration | 设置访问后过期时间voidsetExpireAfterWrite(Duration expireAfterWrite) Sets the expire-after-write duration | 设置写入后过期时间voidsetInitialCapacity(int initialCapacity) Sets the initial capacity | 设置初始容量voidsetMaximumSize(long maximumSize) Sets the maximum size | 设置最大大小voidsetMaximumWeight(long maximumWeight) Sets the maximum weight | 设置最大权重voidsetMetricsEnabled(boolean metricsEnabled) Sets whether metrics export is enabled | 设置是否启用指标导出voidsetRecordStats(boolean recordStats) Sets whether stats recording is enabled | 设置是否启用统计记录voidsetRefreshAfterWrite(Duration refreshAfterWrite) Sets the refresh-after-write duration | 设置写入后刷新时间voidsetUseVirtualThreads(boolean useVirtualThreads) Sets whether virtual threads are used | 设置是否使用虚拟线程voidvalidate()Validate the cache specification 验证缓存规格
-
Constructor Details
-
CacheSpec
public CacheSpec()Creates a new CacheSpec with defaults | 使用默认值创建新的缓存规格
-
-
Method Details
-
getMaximumSize
public long getMaximumSize()Returns the maximum size | 返回最大大小- Returns:
- maximum size | 最大大小
-
setMaximumSize
public void setMaximumSize(long maximumSize) Sets the maximum size | 设置最大大小- Parameters:
maximumSize- maximum size | 最大大小
-
getMaximumWeight
public long getMaximumWeight()Returns the maximum weight | 返回最大权重- Returns:
- maximum weight | 最大权重
-
setMaximumWeight
public void setMaximumWeight(long maximumWeight) Sets the maximum weight | 设置最大权重- Parameters:
maximumWeight- maximum weight | 最大权重
-
getExpireAfterWrite
Returns the expire-after-write duration | 返回写入后过期时间- Returns:
- expire-after-write | 写入后过期时间
-
setExpireAfterWrite
Sets the expire-after-write duration | 设置写入后过期时间- Parameters:
expireAfterWrite- the duration | 过期时间
-
getExpireAfterAccess
Returns the expire-after-access duration | 返回访问后过期时间- Returns:
- expire-after-access | 访问后过期时间
-
setExpireAfterAccess
Sets the expire-after-access duration | 设置访问后过期时间- Parameters:
expireAfterAccess- the duration | 过期时间
-
getRefreshAfterWrite
Returns the refresh-after-write duration | 返回写入后刷新时间- Returns:
- refresh-after-write | 写入后刷新时间
-
setRefreshAfterWrite
Sets the refresh-after-write duration | 设置写入后刷新时间- Parameters:
refreshAfterWrite- the duration | 刷新时间
-
getInitialCapacity
public int getInitialCapacity()Returns the initial capacity | 返回初始容量- Returns:
- initial capacity | 初始容量
-
setInitialCapacity
public void setInitialCapacity(int initialCapacity) Sets the initial capacity | 设置初始容量- Parameters:
initialCapacity- initial capacity | 初始容量
-
getConcurrencyLevel
public int getConcurrencyLevel()Returns the concurrency level | 返回并发级别- Returns:
- concurrency level | 并发级别
-
setConcurrencyLevel
public void setConcurrencyLevel(int concurrencyLevel) Sets the concurrency level | 设置并发级别- Parameters:
concurrencyLevel- concurrency level | 并发级别
-
isRecordStats
public boolean isRecordStats()Returns whether stats recording is enabled | 返回是否启用统计记录- Returns:
- true if enabled | 启用返回 true
-
setRecordStats
public void setRecordStats(boolean recordStats) Sets whether stats recording is enabled | 设置是否启用统计记录- Parameters:
recordStats- true to enable | true 为启用
-
isUseVirtualThreads
public boolean isUseVirtualThreads()Returns whether virtual threads are used | 返回是否使用虚拟线程- Returns:
- true if enabled | 启用返回 true
-
setUseVirtualThreads
public void setUseVirtualThreads(boolean useVirtualThreads) Sets whether virtual threads are used | 设置是否使用虚拟线程- Parameters:
useVirtualThreads- true to enable | true 为启用
-
getEvictionPolicy
Returns the eviction policy name | 返回淘汰策略名称- Returns:
- eviction policy | 淘汰策略
-
setEvictionPolicy
Sets the eviction policy name | 设置淘汰策略名称- Parameters:
evictionPolicy- eviction policy | 淘汰策略
-
isMetricsEnabled
public boolean isMetricsEnabled()Returns whether metrics export is enabled | 返回是否启用指标导出- Returns:
- true if enabled | 启用返回 true
-
setMetricsEnabled
public void setMetricsEnabled(boolean metricsEnabled) Sets whether metrics export is enabled | 设置是否启用指标导出- Parameters:
metricsEnabled- true to enable | true 为启用
-
validate
public void validate()Validate the cache specification 验证缓存规格- Throws:
IllegalArgumentException- if configuration is invalid | 如果配置无效抛出异常- Since:
- V2.0.1
-