Mnemonix v0.1.0 Mnemonix.Store
Normalizes access to different key-value stores behind a GenServer
.
Once a store has been started, you can use Mnemonix
methods to manipulate it:
iex> Mnemonix.Store.start_link(Mnemonix.Map.Store, name: Store)
iex> Mnemonix.put(Store, :foo, "bar")
iex> Mnemonix.get(Store, :foo)
"bar"
iex> Mnemonix.delete(Store, :foo)
iex> Mnemonix.get(Store, :foo)
nil
Summary
Types
A module implementing Mnemonix.Store.Behaviour
Adapter and optional initialization options for start_link/1
Keys allowed in Mnemonix entries
Options supplied to Mnemonix.Store.Behaviour.init/1
to initialize the adapter/0
Values allowed in Mnemonix entries
Functions
Starts a new Mnemonix.Store
using adapter
Starts a new Mnemonix.Store
using adapter
with opts
Types
A module implementing Mnemonix.Store.Behaviour
.
Adapter and optional initialization options for start_link/1
.
Keys allowed in Mnemonix entries.
Options supplied to Mnemonix.Store.Behaviour.init/1
to initialize the adapter/0
.
Values allowed in Mnemonix entries.
Functions
start_link(adapter) :: GenServer.on_start
start_link({adapter, opts}) :: GenServer.on_start
Starts a new Mnemonix.Store
using adapter
.
If you wish to pass options to GenServer.start_link/3
, use start_link/2
.
The returned GenServer.on_start/0
reference can be used in the Mnemonix
API.
Examples
iex> {:ok, store} = Mnemonix.Store.start_link(Mnemonix.Map.Store)
iex> Mnemonix.put(store, :foo, :bar)
iex> Mnemonix.get(store, :foo)
:bar
iex> {:ok, store} = Mnemonix.Store.start_link({Mnemonix.Map.Store, initial: %{foo: :bar}})
iex> Mnemonix.get(store, :foo)
:bar
start_link({adapter, opts}, GenServer.options) :: GenServer.on_start
start_link(adapter, GenServer.options) :: GenServer.on_start
Starts a new Mnemonix.Store
using adapter
with opts
.
The returned GenServer.on_start/0
reference can be used in the Mnemonix
API.
Examples
iex> {:ok, store} = Mnemonix.Store.start_link(Mnemonix.Map.Store, name: Cache)
iex> Mnemonix.put(Cache, :foo, :bar)
iex> Mnemonix.get(Cache, :foo)
:bar
iex> {:ok, store} = Mnemonix.Store.start_link({Mnemonix.Map.Store, initial: %{foo: :bar}}, name: Cache)
iex> Mnemonix.get(Cache, :foo)
:bar