Record Class DistributedCacheConfig
java.lang.Object
java.lang.Record
cloud.opencode.base.cache.distributed.DistributedCacheConfig
- Record Components:
name- the cache name | 缓存名称keyPrefix- the key prefix for namespacing | 键前缀(用于命名空间)defaultTtl- the default time-to-live | 默认过期时间connectionTimeout- the connection timeout | 连接超时时间operationTimeout- the operation timeout | 操作超时时间maxRetries- the maximum number of retries | 最大重试次数retryBackoff- the backoff duration between retries | 重试间隔enableCompression- whether to enable value compression | 是否启用值压缩compressionThreshold- the compression threshold in bytes | 压缩阈值(字节)enableStats- whether to enable statistics | 是否启用统计enableLocalCache- whether to enable local cache | 是否启用本地缓存localCacheSize- the local cache size | 本地缓存大小localCacheTtl- the local cache TTL | 本地缓存过期时间keySerializer- the key serializer | 键序列化器valueSerializer- the value serializer | 值序列化器invalidationChannel- the cache invalidation channel name | 缓存失效通道名称
public record DistributedCacheConfig(String name, String keyPrefix, Duration defaultTtl, Duration connectionTimeout, Duration operationTimeout, int maxRetries, Duration retryBackoff, boolean enableCompression, int compressionThreshold, boolean enableStats, boolean enableLocalCache, int localCacheSize, Duration localCacheTtl, CacheSerializer<?> keySerializer, CacheSerializer<?> valueSerializer, String invalidationChannel)
extends Record
Configuration for Distributed Cache
分布式缓存配置
Provides configuration options for distributed cache implementations.
为分布式缓存实现提供配置选项。
Usage Example | 使用示例:
DistributedCacheConfig config = DistributedCacheConfig.builder()
.name("user-cache")
.keyPrefix("user:")
.defaultTtl(Duration.ofHours(1))
.connectionTimeout(Duration.ofSeconds(5))
.operationTimeout(Duration.ofSeconds(1))
.maxRetries(3)
.enableCompression(true)
.compressionThreshold(1024)
.build();
Features | 主要功能:
- Connection and operation timeout configuration - 连接和操作超时配置
- Key prefix support - 键前缀支持
- Compression configuration - 压缩配置
- Retry configuration - 重试配置
Usage Examples | 使用示例:
DistributedCacheConfig config = DistributedCacheConfig.builder()
.name("users")
.keyPrefix("user:")
.defaultTtl(Duration.ofHours(1))
.build();
Security | 安全性:
- Thread-safe: Yes (immutable record) - 线程安全: 是(不可变记录)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-cache V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for DistributedCacheConfig. -
Constructor Summary
ConstructorsConstructorDescriptionDistributedCacheConfig(String name, String keyPrefix, Duration defaultTtl, Duration connectionTimeout, Duration operationTimeout, int maxRetries, Duration retryBackoff, boolean enableCompression, int compressionThreshold, boolean enableStats, boolean enableLocalCache, int localCacheSize, Duration localCacheTtl, CacheSerializer<?> keySerializer, CacheSerializer<?> valueSerializer, String invalidationChannel) Creates an instance of aDistributedCacheConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Creates a new builder.intReturns the value of thecompressionThresholdrecord component.Returns the value of theconnectionTimeoutrecord component.Returns the value of thedefaultTtlrecord component.booleanReturns the value of theenableCompressionrecord component.booleanReturns the value of theenableLocalCacherecord component.booleanReturns the value of theenableStatsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinvalidationChannelrecord component.Returns the value of thekeyPrefixrecord component.Returns the value of thekeySerializerrecord component.intReturns the value of thelocalCacheSizerecord component.Returns the value of thelocalCacheTtlrecord component.intReturns the value of themaxRetriesrecord component.name()Returns the value of thenamerecord component.Returns the value of theoperationTimeoutrecord component.Returns the value of theretryBackoffrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalueSerializerrecord component.static DistributedCacheConfigwithDefaults(String name) Creates a default configuration with the given name.
-
Constructor Details
-
DistributedCacheConfig
public DistributedCacheConfig(String name, String keyPrefix, Duration defaultTtl, Duration connectionTimeout, Duration operationTimeout, int maxRetries, Duration retryBackoff, boolean enableCompression, int compressionThreshold, boolean enableStats, boolean enableLocalCache, int localCacheSize, Duration localCacheTtl, CacheSerializer<?> keySerializer, CacheSerializer<?> valueSerializer, String invalidationChannel) Creates an instance of aDistributedCacheConfigrecord class.- Parameters:
name- the value for thenamerecord componentkeyPrefix- the value for thekeyPrefixrecord componentdefaultTtl- the value for thedefaultTtlrecord componentconnectionTimeout- the value for theconnectionTimeoutrecord componentoperationTimeout- the value for theoperationTimeoutrecord componentmaxRetries- the value for themaxRetriesrecord componentretryBackoff- the value for theretryBackoffrecord componentenableCompression- the value for theenableCompressionrecord componentcompressionThreshold- the value for thecompressionThresholdrecord componentenableStats- the value for theenableStatsrecord componentenableLocalCache- the value for theenableLocalCacherecord componentlocalCacheSize- the value for thelocalCacheSizerecord componentlocalCacheTtl- the value for thelocalCacheTtlrecord componentkeySerializer- the value for thekeySerializerrecord componentvalueSerializer- the value for thevalueSerializerrecord componentinvalidationChannel- the value for theinvalidationChannelrecord component
-
-
Method Details
-
builder
Creates a new builder. 创建新的构建器。- Returns:
- the builder - 构建器
-
withDefaults
Creates a default configuration with the given name. 使用给定名称创建默认配置。- Parameters:
name- the cache name - 缓存名称- Returns:
- the config - 配置
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
name
-
keyPrefix
-
defaultTtl
Returns the value of thedefaultTtlrecord component.- Returns:
- the value of the
defaultTtlrecord component
-
connectionTimeout
Returns the value of theconnectionTimeoutrecord component.- Returns:
- the value of the
connectionTimeoutrecord component
-
operationTimeout
Returns the value of theoperationTimeoutrecord component.- Returns:
- the value of the
operationTimeoutrecord component
-
maxRetries
public int maxRetries()Returns the value of themaxRetriesrecord component.- Returns:
- the value of the
maxRetriesrecord component
-
retryBackoff
Returns the value of theretryBackoffrecord component.- Returns:
- the value of the
retryBackoffrecord component
-
enableCompression
public boolean enableCompression()Returns the value of theenableCompressionrecord component.- Returns:
- the value of the
enableCompressionrecord component
-
compressionThreshold
public int compressionThreshold()Returns the value of thecompressionThresholdrecord component.- Returns:
- the value of the
compressionThresholdrecord component
-
enableStats
public boolean enableStats()Returns the value of theenableStatsrecord component.- Returns:
- the value of the
enableStatsrecord component
-
enableLocalCache
public boolean enableLocalCache()Returns the value of theenableLocalCacherecord component.- Returns:
- the value of the
enableLocalCacherecord component
-
localCacheSize
public int localCacheSize()Returns the value of thelocalCacheSizerecord component.- Returns:
- the value of the
localCacheSizerecord component
-
localCacheTtl
Returns the value of thelocalCacheTtlrecord component.- Returns:
- the value of the
localCacheTtlrecord component
-
keySerializer
Returns the value of thekeySerializerrecord component.- Returns:
- the value of the
keySerializerrecord component
-
valueSerializer
Returns the value of thevalueSerializerrecord component.- Returns:
- the value of the
valueSerializerrecord component
-
invalidationChannel
Returns the value of theinvalidationChannelrecord component.- Returns:
- the value of the
invalidationChannelrecord component
-