Mnemonix v0.7.1 Mnemonix.Stores.Redix
A Mnemonix.Store
that uses Redix to store state in redis.
iex> {:ok, store} = Mnemonix.Stores.Redix.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
Connects to redis to store data
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Redix
module with options
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Redix
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
.
Connects to redis to store data.
Options
conn:
The Redis to connect to, as either a string or list of opts w/ host, port, password, and database.Default:
"redis://localhost:6379"
initial:
A map of key/value pairs to ensure are set in redis at boot.Default:
%{}
All other options are passed verbatim to Redix.start_link/2
.
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Redix
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.Redix.start_link
iex> Mnemonix.put(store, "foo", "bar")
iex> Mnemonix.get(store, "foo")
"bar"
iex> {:ok, _store} = Mnemonix.Stores.Redix.start_link([], [name: My.Mnemonix.Stores.Redix])
iex> Mnemonix.put(My.Mnemonix.Stores.Redix, "foo", "bar")
iex> Mnemonix.get(My.Mnemonix.Stores.Redix, "foo")
"bar"
start_link(Mnemonix.Store.Server.options, GenServer.options) :: GenServer.on_start
Starts a new Mnemonix.Store.Server
using the Mnemonix.Stores.Redix
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.Redix.start_link([], [])
iex> Mnemonix.put(store, "foo", "bar")
iex> Mnemonix.get(store, "foo")
"bar"
iex> {:ok, _store} = Mnemonix.Stores.Redix.start_link([], [name: My.Mnemonix.Stores.Redix])
iex> Mnemonix.put(My.Mnemonix.Stores.Redix, "foo", "bar")
iex> Mnemonix.get(My.Mnemonix.Stores.Redix, "foo")
"bar"