Class WriteBehindCache.Builder<K,V>
java.lang.Object
cloud.opencode.base.cache.WriteBehindCache.Builder<K,V>
- Type Parameters:
K- key type | 键类型V- value type | 值类型
- Enclosing class:
WriteBehindCache<K,V>
Builder for WriteBehindCache
WriteBehindCache 构建器
- Since:
- JDK 25, opencode-base-cache V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionbatchSize(int batchSize) Set batch size before auto-flush 设置自动刷新前的批量大小build()Build the write-behind cache 构建写后缓存flushInterval(Duration interval) Set flush interval 设置刷新间隔maxQueueSize(int maxQueueSize) Set maximum queue size before synchronous fallback 设置同步回退前的最大队列大小maxRetries(int maxRetries) Set maximum retry attempts on failure 设置失败时的最大重试次数onFailure(Consumer<WriteBehindCache.WriteFailure<K, V>> handler) Set failure handler for write failures after all retries 设置所有重试后写入失败的处理器retryDelay(Duration delay) Set delay between retries 设置重试间隔writer(WriteBehindCache.BatchWriter<K, V> writer) Set the batch writer 设置批量写入器Set writer using simple consumer (puts only) 使用简单消费者设置写入器(仅放入)
-
Method Details
-
writer
Set the batch writer 设置批量写入器- Parameters:
writer- batch writer | 批量写入器- Returns:
- this builder | 此构建器
-
writer
-
batchSize
Set batch size before auto-flush 设置自动刷新前的批量大小- Parameters:
batchSize- batch size | 批量大小- Returns:
- this builder | 此构建器
-
maxQueueSize
Set maximum queue size before synchronous fallback 设置同步回退前的最大队列大小- Parameters:
maxQueueSize- max queue size (default 10000) | 最大队列大小(默认10000)- Returns:
- this builder | 此构建器
-
flushInterval
Set flush interval 设置刷新间隔- Parameters:
interval- flush interval | 刷新间隔- Returns:
- this builder | 此构建器
-
maxRetries
Set maximum retry attempts on failure 设置失败时的最大重试次数- Parameters:
maxRetries- max retries | 最大重试次数- Returns:
- this builder | 此构建器
-
retryDelay
Set delay between retries 设置重试间隔- Parameters:
delay- retry delay | 重试间隔- Returns:
- this builder | 此构建器
-
onFailure
public WriteBehindCache.Builder<K,V> onFailure(Consumer<WriteBehindCache.WriteFailure<K, V>> handler) Set failure handler for write failures after all retries 设置所有重试后写入失败的处理器- Parameters:
handler- failure handler | 失败处理器- Returns:
- this builder | 此构建器
-
build
Build the write-behind cache 构建写后缓存- Returns:
- write-behind cache | 写后缓存
-