Class ResilientCacheLoader.Builder<K,V>

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

public static class ResilientCacheLoader.Builder<K,V> extends Object
Builder for ResilientCacheLoader
Since:
JDK 25, opencode-base-cache V1.9.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Builder

      public Builder()
      Creates a new Builder instance | 创建新的 Builder 实例
  • Method Details

    • loader

      public ResilientCacheLoader.Builder<K,V> loader(Function<K,V> loader)
      Set the base loader function 设置基础加载函数
      Parameters:
      loader - the loader | 加载器
      Returns:
      this builder | 此构建器
    • loader

      public ResilientCacheLoader.Builder<K,V> loader(CacheLoader<K,V> loader)
      Set the base CacheLoader 设置基础 CacheLoader
      Parameters:
      loader - the cache loader | 缓存加载器
      Returns:
      this builder | 此构建器
    • retry

      public ResilientCacheLoader.Builder<K,V> retry(RetryPolicy retryPolicy)
      Set retry policy 设置重试策略
      Parameters:
      retryPolicy - the policy | 策略
      Returns:
      this builder | 此构建器
    • circuitBreaker

      public ResilientCacheLoader.Builder<K,V> circuitBreaker(CircuitBreaker circuitBreaker)
      Set circuit breaker 设置熔断器
      Parameters:
      circuitBreaker - the circuit breaker | 熔断器
      Returns:
      this builder | 此构建器
    • bulkhead

      public ResilientCacheLoader.Builder<K,V> bulkhead(Bulkhead bulkhead)
      Set bulkhead 设置舱壁
      Parameters:
      bulkhead - the bulkhead | 舱壁
      Returns:
      this builder | 此构建器
    • timeout

      public ResilientCacheLoader.Builder<K,V> timeout(Duration timeout)
      Set operation timeout 设置操作超时
      Parameters:
      timeout - the timeout | 超时
      Returns:
      this builder | 此构建器
    • fallback

      public ResilientCacheLoader.Builder<K,V> fallback(Function<Throwable, V> fallback)
      Set fallback function 设置回退函数
      Parameters:
      fallback - fallback for exceptions | 异常回退
      Returns:
      this builder | 此构建器
    • fallbackValue

      public ResilientCacheLoader.Builder<K,V> fallbackValue(V value)
      Set fallback value 设置回退值
      Parameters:
      value - fallback value | 回退值
      Returns:
      this builder | 此构建器
    • build

      public Function<K,V> build()
      Build the resilient loader 构建弹性加载器
      Returns:
      resilient loader function | 弹性加载器函数