Mnemonix v0.4.0 Mnemonix.Memcachex.Store

A Mnemonix.Store that uses Memcachex to store state in memcached.

iex> {:ok, store} = Mnemonix.Memcachex.Store.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.Core.Behaviour.delete/2

Callback implementation for c:Mnemonix.Store.Core.Behaviour.fetch/2

Callback implementation for c:Mnemonix.Store.Core.Behaviour.put/3

Connects to memcached to store data

Starts a new Mnemonix.Store using the Mnemonix.Memcachex.Store module with init opts

Functions

delete(store, key)
delete(store, key) :: {:ok, store} | exception

Callback implementation for c:Mnemonix.Store.Core.Behaviour.delete/2.

fetch(store, key)
fetch(store, key) ::
  {:ok, store, {:ok, value} | :error} |
  exception

Callback implementation for c:Mnemonix.Store.Core.Behaviour.fetch/2.

put(store, key, value)
put(store, key, Mnemonix.Store.value) ::
  {:ok, store} |
  exception

Callback implementation for c:Mnemonix.Store.Core.Behaviour.put/3.

setup(opts)
setup(opts) :: {:ok, state}

Connects to memcached to store data.

All options are passed verbatim to Memcache.start_link/1.

start_link(opts \\ [])

Starts a new Mnemonix.Store using the Mnemonix.Memcachex.Store module.

If you wish to pass configuration options to the module instead, use start_link/2 with an empty opts list.

The returned GenServer.server/0 reference can be used as the primary argument to the Mnemonix API.

Examples

iex> {:ok, store} = Mnemonix.Memcachex.Store.start_link
iex> Mnemonix.put(store, :foo, "bar")
iex> Mnemonix.fetch(store, :foo)
{:ok, "bar"}
iex> Mnemonix.delete(store, :foo)
iex> Mnemonix.fetch(store, :foo)
:error
start_link(init, opts)

Starts a new Mnemonix.Store using the Mnemonix.Memcachex.Store module with init opts.

The returned GenServer.server/0 reference can be used as the primary argument to the Mnemonix API.