Mnemonix v0.6.2 Mnemonix.Stores.Mnesia
A Mnemonix.Store
that uses a Mnesia table to store state.
Before using, your current node should be part of a Mnesia schema and the Mnesia application must have been started.
iex> {:ok, store} = Mnemonix.Stores.Mnesia.start_link
iex> Mnemonix.put(store, "foo", "bar")
iex> Mnemonix.get(store, "foo")
"bar"
iex> Mnemonix.delete(store, "foo")
iex> Mnemonix.get(store, "foo")
nil
Summary
Functions
Callback implementation for c:Mnemonix.Store.Behaviours.Map.delete/2
Callback implementation for c:Mnemonix.Store.Behaviours.Map.fetch/2
Callback implementation for c:Mnemonix.Store.Behaviours.Map.put/3
Creates a Mnesia table to store state in
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Mnesia
module with options
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Mnesia
with store
and server
options
Functions
delete(Mnemonix.Store.t, Mnemonix.key) :: {:ok, Mnemonix.Store.t} | Mnemonix.Store.Behaviour.exception
Callback implementation for c:Mnemonix.Store.Behaviours.Map.delete/2
.
fetch(Mnemonix.Store.t, Mnemonix.key) :: {:ok, Mnemonix.Store.t, {:ok, Mnemonix.value} | :error} | Mnemonix.Store.Behaviour.exception
Callback implementation for c:Mnemonix.Store.Behaviours.Map.fetch/2
.
put(Mnemonix.Store.t, Mnemonix.key, Mnemonix.Store.value) :: {:ok, Mnemonix.Store.t} | Mnemonix.Store.Behaviour.exception
Callback implementation for c:Mnemonix.Store.Behaviours.Map.put/3
.
Creates a Mnesia table to store state in.
If the table specified already exists, it will use that instead.
Options
table:
Name of the table to use, will be created if it doesn’t exist.Default:
Mnemonix.Stores.Mnesia.Table
transactional
: Whether or not to perform transactional reads or writes.
Allowed: :reads | :writes | :both | nil
Default: :both
The rest of the options are passed into :dets.open_file/2
verbaitm, except
for type:
, which will always be :set
.
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Mnesia
module with options
.
The options
are the same as described in Mnemonix.Store.Server.start_link/2
.
The returned GenServer.server/0
reference can be used as the primary
argument to the Mnemonix
API.
Examples
iex> {:ok, store} = Mnemonix.Stores.Mnesia.start_link
iex> Mnemonix.put(store, "foo", "bar")
iex> Mnemonix.get(store, "foo")
"bar"
iex> {:ok, _store} = Mnemonix.Stores.Mnesia.start_link([], [name: My.Mnemonix.Stores.Mnesia])
iex> Mnemonix.put(My.Mnemonix.Stores.Mnesia, "foo", "bar")
iex> Mnemonix.get(My.Mnemonix.Stores.Mnesia, "foo")
"bar"
start_link(Mnemonix.Store.Server.options, GenServer.options) :: GenServer.on_start
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Mnesia
with store
and server
options.
The options are the same as described in Mnemonix.Store.Server.start_link/3
.
The returned GenServer.server/0
reference can be used as the primary
argument to the Mnemonix
API.
Examples
iex> {:ok, store} = Mnemonix.Stores.Mnesia.start_link([], [])
iex> Mnemonix.put(store, "foo", "bar")
iex> Mnemonix.get(store, "foo")
"bar"
iex> {:ok, _store} = Mnemonix.Stores.Mnesia.start_link([], [name: My.Mnemonix.Stores.Mnesia])
iex> Mnemonix.put(My.Mnemonix.Stores.Mnesia, "foo", "bar")
iex> Mnemonix.get(My.Mnemonix.Stores.Mnesia, "foo")
"bar"