Interface RingbufferStore<T>

Type Parameters:
T - ringbuffer item type

public interface RingbufferStore<T>
Service Provider Interface (SPI) for backing a DistributedRingbuffer with an external persistent store.

Implementations are expected to be thread-safe. LoomCache invokes store callbacks from ringbuffer operations and does not serialize access outside the owning ringbuffer instance.

A store failure during store(long, Object) prevents the item from being appended in memory so persisted sequence state does not lag the ringbuffer. Reads for sequences no longer present in memory may call load(long).

  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Return the largest sequence currently known to the store.
    @Nullable T
    load(long sequence)
    Load a previously persisted item by sequence.
    void
    store(long sequence, T data)
    Persist one item with its sequence.
    default void
    storeAll(long firstItemSequence, List<? extends T> items)
    Persist multiple consecutive items.
  • Method Details

    • store

      void store(long sequence, T data)
      Persist one item with its sequence.
      Parameters:
      sequence - monotonically increasing ringbuffer sequence
      data - item to persist
    • storeAll

      default void storeAll(long firstItemSequence, List<? extends T> items)
      Persist multiple consecutive items. Override when the backing store can batch writes more efficiently.
      Parameters:
      firstItemSequence - sequence of the first item
      items - consecutive items to persist
    • load

      @Nullable T load(long sequence)
      Load a previously persisted item by sequence.
      Parameters:
      sequence - sequence to load
      Returns:
      persisted item, or null when absent
    • getLargestSequence

      long getLargestSequence()
      Return the largest sequence currently known to the store.

      Return -1 when the store is empty or cannot determine a largest sequence. LoomCache uses this during store wire-up to make the next append continue after already persisted data.

      Returns:
      largest persisted sequence, or -1