Jido.Storage.ETS
(Jido v2.0.0-rc.4)
View Source
ETS-based storage adapter for agent checkpoints and thread journals.
Fast in-memory storage for development and testing. Not restart-safe - all data is lost when the BEAM stops.
Usage
defmodule MyApp.Jido do
use Jido,
otp_app: :my_app,
storage: {Jido.Storage.ETS, table: :my_jido_storage}
endOptions
:table- Base table name (default::jido_storage). Creates three tables:{table, :checkpoints}- Agent checkpoint data (set){table, :threads}- Thread entries ordered by{thread_id, seq}(ordered_set){table, :thread_meta}- Thread metadata (set)
Concurrency
Thread operations use atomic ETS operations. The expected_rev option in
append_thread/3 provides optimistic concurrency control.
Summary
Functions
Append entries to a thread.
Delete a checkpoint by key.
Delete a thread and all its entries.
Retrieve a checkpoint by key.
Load a thread by ID, reconstructing from stored entries.
Store a checkpoint, overwriting any existing value.
Types
@type opts() :: keyword()
Functions
@spec append_thread(String.t(), [Jido.Thread.Entry.t()], opts()) :: {:ok, Jido.Thread.t()} | {:error, term()}
Append entries to a thread.
Options
:expected_rev- If provided, the append will fail with{:error, :conflict}if the current thread revision doesn't match.:metadata- Thread metadata to merge (only used when creating new thread).
Delete a checkpoint by key.
Delete a thread and all its entries.
Retrieve a checkpoint by key.
Returns {:ok, data} if found, :not_found otherwise.
@spec load_thread(String.t(), opts()) :: {:ok, Jido.Thread.t()} | :not_found | {:error, term()}
Load a thread by ID, reconstructing from stored entries.
Returns {:ok, thread} if entries exist, :not_found otherwise.
Store a checkpoint, overwriting any existing value.