Mnemonix v0.4.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.fetch(Store, :foo)
{:ok, "bar"}
iex> Mnemonix.delete(Store, :foo)
iex> Mnemonix.fetch(Store, :foo)
:error
Summary
Types
The return value of a bump operation
A module implementing Mnemonix.Store.Behaviour
Adapter and optional initialization options for start_link/1
Keys allowed in Mnemonix entries
The number of milliseconds an entry will be allowed to exist
Values allowed in Mnemonix entries
Functions
Prepares the underlying store type for usage with supplied options
Starts a new Mnemonix.Store
using impl
Starts a new Mnemonix.Store
using impl
with opts
Types
The return value of a bump operation.
A module implementing Mnemonix.Store.Behaviour
.
Adapter and optional initialization options for start_link/1
.
Keys allowed in Mnemonix entries.
Options supplied to c:Mnemonix.Store.Lifecycle.Behaviour.setup/1
to initialize
the impl/0
.
The number of milliseconds an entry will be allowed to exist.
Values allowed in Mnemonix entries.
Functions
Prepares the underlying store type for usage with supplied options.
Invokes the setup/1
callback and initialization callbacks required by store utilities:
c:Mnemonix.Expiry.Behaviour.setup_expiry/1
start_link(impl) :: GenServer.on_start
start_link({impl, opts}) :: GenServer.on_start
Starts a new Mnemonix.Store
using impl
.
If you wish to pass options to GenServer.start_link/3
, use start_link/2
.
The returned GenServer.server/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({impl, opts}, GenServer.options) :: GenServer.on_start
start_link(impl, GenServer.options) :: GenServer.on_start
Starts a new Mnemonix.Store
using impl
with opts
.
The returned GenServer.server/0
reference can be used in
the Mnemonix
API.
Examples
iex> {:ok, _store} = Mnemonix.Store.start_link(Mnemonix.Map.Store, name: StoreCache)
iex> Mnemonix.put(StoreCache, :foo, :bar)
iex> Mnemonix.get(StoreCache, :foo)
:bar
iex> {:ok, _store} = Mnemonix.Store.start_link({Mnemonix.Map.Store, initial: %{foo: :bar}}, name: OtherCache)
iex> Mnemonix.get(OtherCache, :foo)
:bar