GenServer owning ETS tables for a Store implementation.
Tables are :protected — any BEAM process can read directly via ETS,
but only this GenServer can write. This gives lock-free concurrent
reads with serialized write consistency.
Summary
Functions
Bulk insert an enumerable of records into a table. Serialized.
Returns a specification to start this module under a supervisor.
Delete a key from a table. Serialized.
Fold over all entries in a table. Lock-free.
Read a value from a store's table. Lock-free, no GenServer call.
Read a value, raising if not found.
Match objects in a table. Lock-free.
Insert a key-value pair into a table. Serialized.
Reload all tables by re-running the store's load/1 callback.
Creates new tables, loads data, then atomically swaps pointers.
Select from a table using a match spec. Lock-free.
Get the number of entries in a table. Lock-free.
Atomically read-modify-write a value. Serialized.
Functions
@spec bulk_insert(GenServer.server(), atom(), Enumerable.t()) :: :ok
Bulk insert an enumerable of records into a table. Serialized.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec delete(GenServer.server(), atom(), term()) :: :ok
Delete a key from a table. Serialized.
Fold over all entries in a table. Lock-free.
Read a value from a store's table. Lock-free, no GenServer call.
Read a value, raising if not found.
Match objects in a table. Lock-free.
@spec put(GenServer.server(), atom(), term(), term()) :: :ok
Insert a key-value pair into a table. Serialized.
@spec reload(GenServer.server()) :: :ok | {:error, term()}
Reload all tables by re-running the store's load/1 callback.
Creates new tables, loads data, then atomically swaps pointers.
@spec select(module(), atom(), :ets.match_spec()) :: [term()]
Select from a table using a match spec. Lock-free.
@spec size(module(), atom()) :: non_neg_integer()
Get the number of entries in a table. Lock-free.
@spec update(GenServer.server(), atom(), term(), (term() -> term())) :: {:ok, term()} | {:error, :not_found}
Atomically read-modify-write a value. Serialized.