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 Details
-
store
Persist one item with its sequence.- Parameters:
sequence- monotonically increasing ringbuffer sequencedata- item to persist
-
storeAll
-
load
Load a previously persisted item by sequence.- Parameters:
sequence- sequence to load- Returns:
- persisted item, or
nullwhen absent
-
getLargestSequence
long getLargestSequence()Return the largest sequence currently known to the store.Return
-1when 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
-