Class CacheDecorators.ChainBuilder<K,V>

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

public static class CacheDecorators.ChainBuilder<K,V> extends Object
Builder for chaining cache decorators 用于链式组合缓存装饰器的构建器
Since:
JDK 25, opencode-base-cache V2.0.2
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • withProtection

      public CacheDecorators.ChainBuilder<K,V> withProtection()
      Add protection (BloomFilter + SingleFlight) with default settings 添加保护(布隆过滤器 + SingleFlight)使用默认设置
      Returns:
      this builder | 此构建器
    • withProtection

      public CacheDecorators.ChainBuilder<K,V> withProtection(UnaryOperator<ProtectedCache.Builder<K,V>> configurer)
      Add protection with custom configuration 添加保护并自定义配置
      Parameters:
      configurer - configuration function | 配置函数
      Returns:
      this builder | 此构建器
    • withRefreshAhead

      public CacheDecorators.ChainBuilder<K,V> withRefreshAhead(RefreshAheadPolicy<K,V> policy, Function<? super K, ? extends V> loader)
      Add refresh-ahead behavior 添加提前刷新行为
      Parameters:
      policy - the refresh policy | 刷新策略
      loader - the value loader | 值加载器
      Returns:
      this builder | 此构建器
    • withRefreshAhead

      public CacheDecorators.ChainBuilder<K,V> withRefreshAhead(UnaryOperator<RefreshAheadCache.Builder<K,V>> configurer)
      Add refresh-ahead with custom configuration 添加提前刷新并自定义配置
      Parameters:
      configurer - configuration function | 配置函数
      Returns:
      this builder | 此构建器
    • withTimeout

      public CacheDecorators.ChainBuilder<K,V> withTimeout(Duration timeout)
      Add operation timeout 添加操作超时
      Parameters:
      timeout - the timeout duration | 超时时长
      Returns:
      this builder | 此构建器
    • withTimeout

      Add timeout with custom configuration 添加超时并自定义配置
      Parameters:
      configurer - configuration function | 配置函数
      Returns:
      this builder | 此构建器
    • withCopyOnRead

      public CacheDecorators.ChainBuilder<K,V> withCopyOnRead()
      Add copy-on-read behavior with default copier (serialization) 添加读时复制行为,使用默认复制器(序列化)
      Returns:
      this builder | 此构建器
    • withCopyOnRead

      public CacheDecorators.ChainBuilder<K,V> withCopyOnRead(UnaryOperator<V> copier)
      Add copy-on-read with custom copier 添加读时复制并自定义复制器
      Parameters:
      copier - the value copier function | 值复制函数
      Returns:
      this builder | 此构建器
    • withCopyOnReadConfigured

      public CacheDecorators.ChainBuilder<K,V> withCopyOnReadConfigured(UnaryOperator<CopyOnReadCache.Builder<K,V>> configurer)
      Add copy-on-read with custom configuration 添加读时复制并自定义配置
      Parameters:
      configurer - configuration function | 配置函数
      Returns:
      this builder | 此构建器
    • with

      public CacheDecorators.ChainBuilder<K,V> with(UnaryOperator<Cache<K,V>> decorator)
      Apply a custom decorator 应用自定义装饰器
      Parameters:
      decorator - the decorator function | 装饰器函数
      Returns:
      this builder | 此构建器
    • build

      public Cache<K,V> build()
      Build the decorated cache 构建装饰后的缓存
      Returns:
      the decorated cache | 装饰后的缓存