Jido.RuntimeStore (Jido v2.2.0)

View Source

Instance-scoped runtime key/value store for mutable Jido coordination state.

RuntimeStore is an internal control-plane store owned by each Jido instance. It backs ephemeral runtime data that needs a stable home outside individual agent processes, such as logical parent-child relationship bindings.

The ETS table itself is owned by the Jido instance supervisor, while the RuntimeStore process provides the logical API. That lets the table survive RuntimeStore process restarts without making it durable beyond the life of the owning Jido instance.

Values are organized into named hives so unrelated runtime concerns can share the same store without colliding:

:ok = Jido.RuntimeStore.put(MyApp.Jido, :relationships, "child-1", %{parent_id: "p-1"})
{:ok, binding} = Jido.RuntimeStore.fetch(MyApp.Jido, :relationships, "child-1")
:ok = Jido.RuntimeStore.delete(MyApp.Jido, :relationships, "child-1")

The store is intentionally ephemeral. It is reset when the owning Jido instance stops or restarts.

Summary

Functions

Deletes a value from the given hive.

Fetches a value from the given hive.

Returns a value from the given hive, or default when no value exists.

Lists all {key, value} entries in the given hive.

Stores a value in the given hive.

Starts a RuntimeStore process.

Types

hive()

@type hive() :: term()

key()

@type key() :: term()

state()

@type state() :: %{table: atom()}

value()

@type value() :: term()

Functions

delete(instance, hive, key)

@spec delete(atom(), hive(), key()) :: :ok | {:error, term()}

Deletes a value from the given hive.

fetch(instance, hive, key)

@spec fetch(atom(), hive(), key()) :: {:ok, value()} | :error

Fetches a value from the given hive.

Returns {:ok, value} when present, or :error when the key or store is unavailable.

get(instance, hive, key, default \\ nil)

@spec get(atom(), hive(), key(), value()) :: value()

Returns a value from the given hive, or default when no value exists.

list(instance, hive)

@spec list(atom(), hive()) :: [{key(), value()}]

Lists all {key, value} entries in the given hive.

put(instance, hive, key, value)

@spec put(atom(), hive(), key(), value()) :: :ok | {:error, term()}

Stores a value in the given hive.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts a RuntimeStore process.