Module methanol

Interface Store

All Superinterfaces:
AutoCloseable, Closeable, Flushable
All Known Implementing Classes:
DiskStore, MemoryStore

public interface Store extends Closeable, Flushable
A repository of binary data entries each identified by a string key. Each entry has a metadata block and a data stream. An entry's metadata block and data stream can be accessed by a Store.Viewer and modified by an Store.Editor. An entry can have at most one active editor but can have multiple concurrent viewers. No data written through an editor is visible to subsequently opened viewers unless committed. A viewer sees a consistent snapshot of the entry as perceived at the time it was opened at.

A store may bound its size by automatic eviction of entries, possibly in background. The size bound is not strict. A store's size() might temporarily exceed its bound in case the store is being actively expanded while eviction is in progress. Additionally, a store's size doesn't include the overhead of the underlying filesystem or any metadata the store itself uses for indexing purposes. Thus, a store's maxSize() is not exact and might be slightly exceeded as necessary.

Entries on a store are volatile. It is not guaranteed that an entry can be viewed any time, even if immediately, after it has been committed.

Functions that are expected to be called frequently have two variants: one synchronous, and another asynchronous variant that takes an additional Executor parameter. The former has a default implementation that calls the latter and waits for the result. The executor parameter only expresses caller's preferred asynchronous execution strategy, and may be ignored by the store if seen fit. The executor parameter can be Runnable::run if same-thread execution is preferred.

Store is thread-safe and is suitable for concurrent use.