Class WriteThroughCache.Builder<K,V>

java.lang.Object
cloud.opencode.base.cache.WriteThroughCache.Builder<K,V>
Type Parameters:
K - key type | 键类型
V - value type | 值类型
Enclosing class:
WriteThroughCache<K,V>

public static class WriteThroughCache.Builder<K,V> extends Object
Builder for WriteThroughCache WriteThroughCache 构建器
Since:
JDK 25, opencode-base-cache V2.0.4
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • writer

      public WriteThroughCache.Builder<K,V> writer(BiConsumer<K,V> writer)
      Set the cache writer for single entry writes 设置单条目写入器
      Parameters:
      writer - the writer function | 写入函数
      Returns:
      this builder | 此构建器
    • writer

      Set the cache writer with full control 设置完整控制的缓存写入器
      Parameters:
      writer - the cache writer | 缓存写入器
      Returns:
      this builder | 此构建器
    • deleter

      public WriteThroughCache.Builder<K,V> deleter(Consumer<K> deleter)
      Set the deleter for cache invalidation 设置删除器用于缓存失效
      Parameters:
      deleter - the deleter function | 删除函数
      Returns:
      this builder | 此构建器
    • onError

      public WriteThroughCache.Builder<K,V> onError(BiConsumer<Iterable<K>, Throwable> errorHandler)
      Set error handler for write failures 设置写入失败的错误处理器
      Parameters:
      errorHandler - the error handler | 错误处理器
      Returns:
      this builder | 此构建器
    • build

      public WriteThroughCache<K,V> build()
      Build the write-through cache 构建写穿透缓存
      Returns:
      write-through cache | 写穿透缓存