AgentForge.Store (AgentForge v0.2.2)
View SourceA simple state container implementation using GenServer. Provides basic operations for state management.
Summary
Functions
Returns a specification to start this module under a supervisor.
Deletes a value from the store.
Gets a value from the store.
Puts a value in the store.
Starts the store process with an optional name.
Updates a value in the store using a function.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Deletes a value from the store.
Examples
iex> {:ok, _} = AgentForge.Store.start_link(name: :test_store4)
iex> AgentForge.Store.delete(:test_store4, :counter)
:ok
Gets a value from the store.
Examples
iex> {:ok, _} = AgentForge.Store.start_link(name: :test_store)
iex> AgentForge.Store.put(:test_store, :counter, 42)
iex> AgentForge.Store.get(:test_store, :counter)
{:ok, 42}
iex> AgentForge.Store.get(:test_store, :nonexistent)
{:error, :not_found}
Puts a value in the store.
Examples
iex> {:ok, _} = AgentForge.Store.start_link(name: :test_store2)
iex> AgentForge.Store.put(:test_store2, :counter, 42)
:ok
Starts the store process with an optional name.
Updates a value in the store using a function.
Examples
iex> {:ok, _} = AgentForge.Store.start_link(name: :test_store3)
iex> AgentForge.Store.update(:test_store3, :counter, 0, &(&1 + 1))
:ok