Class ProtectedCache.Builder<K,V>

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

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

    • bloomFilter

      public ProtectedCache.Builder<K,V> bloomFilter(boolean enable)
      Enable/disable bloom filter 启用/禁用布隆过滤器
      Parameters:
      enable - the enable | enable
      Returns:
      the result | 结果
    • bloomFilter

      public ProtectedCache.Builder<K,V> bloomFilter(long expectedInsertions, double falsePositiveRate)
      Configure bloom filter 配置布隆过滤器
      Parameters:
      expectedInsertions - expected number of insertions | 预期插入数
      falsePositiveRate - false positive rate (0-1) | 误报率
      Returns:
      the result | 结果
    • singleFlight

      public ProtectedCache.Builder<K,V> singleFlight(boolean enable)
      Enable/disable single flight 启用/禁用单次加载
      Parameters:
      enable - the enable | enable
      Returns:
      the result | 结果
    • negativeCache

      public ProtectedCache.Builder<K,V> negativeCache(Duration duration)
      Set negative cache duration 设置负缓存时长
      Parameters:
      duration - how long to cache negative lookups | 负查找缓存时长
      Returns:
      the result | 结果
    • build

      public ProtectedCache<K,V> build()
      Build the protected cache 构建保护缓存
      Returns:
      the result | 结果