In-memory store adapter for testing.
Data is stored in an Agent process and is not persisted to disk. Useful for unit tests and development scenarios where persistence is not required.
Examples
# Create a memory store
store = ExWapp.Store.Memory.new()
# Use in tests
ExWapp.connect(store: ExWapp.Store.Memory)
# Pre-populate with data
store = ExWapp.Store.Memory.new(initial_data: %{foo: "bar"})Testing Usage
defmodule MyTest do
use ExUnit.Case
setup do
store = ExWapp.Store.Memory.new()
{:ok, store: store}
end
test "stores data", %{store: store} do
assert :ok = ExWapp.Store.persist(store, %{key: "value"})
assert {:ok, %{key: "value"}} = ExWapp.Store.load(store)
end
end
Summary
Functions
Stops the underlying Agent process.
Updates specific keys in the store without replacing all data.
Types
@type t() :: %ExWapp.Store.Memory{ agent: pid(), message_table: ExWapp.Store.MessageTable.t() }
Functions
@spec stop(t()) :: :ok
Stops the underlying Agent process.
Call this in test teardown if you want to clean up the process.
Updates specific keys in the store without replacing all data.
This is a convenience function for tests that need to modify specific fields.
Examples
store = ExWapp.Store.Memory.new()
ExWapp.Store.Memory.update(store, :noise, %{static_private: <<...>>})