Interface WriteBehindCache.BatchWriter<K,V>

Type Parameters:
K - key type | 键类型
V - value type | 值类型
Enclosing class:
WriteBehindCache<K,V>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface WriteBehindCache.BatchWriter<K,V>
Batch writer interface for persisting cache changes 批量写入器接口,用于持久化缓存变更
Since:
JDK 25, opencode-base-cache V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Method Summary

    Modifier and Type
    Method
    Description
    static <K,V> WriteBehindCache.BatchWriter<K,V>
    of(Consumer<Map<K,V>> putHandler, Consumer<Set<K>> deleteHandler)
    Create writer with separate put and delete handlers 创建分别处理放入和删除的写入器
    static <K,V> WriteBehindCache.BatchWriter<K,V>
    putsOnly(Consumer<Map<K,V>> consumer)
    Create writer for puts only 创建仅处理放入的写入器
    void
    writeBatch(Map<K,V> puts, Set<K> deletes)
    Write batch of changes to underlying store 将批量变更写入底层存储
  • Method Details

    • writeBatch

      void writeBatch(Map<K,V> puts, Set<K> deletes) throws Exception
      Write batch of changes to underlying store 将批量变更写入底层存储
      Parameters:
      puts - entries to put/update | 要放入/更新的条目
      deletes - keys to delete | 要删除的键
      Throws:
      Exception - on write failure | 写入失败时抛出异常
    • putsOnly

      static <K,V> WriteBehindCache.BatchWriter<K,V> putsOnly(Consumer<Map<K,V>> consumer)
      Create writer for puts only 创建仅处理放入的写入器
      Type Parameters:
      K - key type | 键类型
      V - value type | 值类型
      Parameters:
      consumer - put consumer | 放入消费者
      Returns:
      batch writer | 批量写入器
    • of

      static <K,V> WriteBehindCache.BatchWriter<K,V> of(Consumer<Map<K,V>> putHandler, Consumer<Set<K>> deleteHandler)
      Create writer with separate put and delete handlers 创建分别处理放入和删除的写入器
      Type Parameters:
      K - key type | 键类型
      V - value type | 值类型
      Parameters:
      putHandler - put handler | 放入处理器
      deleteHandler - delete handler | 删除处理器
      Returns:
      batch writer | 批量写入器