Mnemonix v0.5.0 Mnemonix.Store.Server

Bridges Mnemonix.Features with underlying Mnemonix.Stores.

Summary

Types

Adapter and optional initialization options for Mnemonix.Store.Server.start_link/1

Options supplied to c:Mnemonix.Store.Behaviours.Core.setup/1 to initialize the t:impl/0

Functions

Delegates Mnemonix.API functions to the underlying store behaviours

Prepares the underlying store type for usage with supplied options

Starts a new Mnemonix.Store.Server using impl

Starts a new Mnemonix.Store.Server using impl with opts

Cleans up the underlying store on termination

Types

init()
init ::
  Mnemonix.Store.Behaviour.t |
  {Mnemonix.Store.Behaviour.t, options}

Adapter and optional initialization options for Mnemonix.Store.Server.start_link/1.

options()

Options supplied to c:Mnemonix.Store.Behaviours.Core.setup/1 to initialize the t:impl/0.

Functions

handle_call(msg, from, state)
handle_call(request :: term, GenServer.from, Mnemonix.Store.t) ::
  {:reply, reply, new_store} |
  {:reply, reply, new_store, timeout | :hibernate} |
  {:noreply, new_store} |
  {:noreply, new_store, timeout | :hibernate} |
  {:stop, reason, reply, new_store} |
  {:stop, reason, new_store} when reply: term, new_store: Mnemonix.Store.t, reason: term, timeout: pos_integer

Delegates Mnemonix.API functions to the underlying store behaviours.

init(args)
init({Mnemonix.Store.Behaviour.t, options}) ::
  {:ok, Mnemonix.Store.t} |
  :ignore |
  {:stop, reason :: term}

Prepares the underlying store type for usage with supplied options.

Invokes the c:Mnemonix.Core.Behaviour.setup/1 and c:Mnemonix.Expiry.Behaviour.setup_expiry/1 callbacks.

start_link(init)
start_link(init) :: GenServer.on_start

Starts a new Mnemonix.Store.Server 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.Server.start_link(Mnemonix.Stores.Map) iex> Mnemonix.put(store, :foo, :bar) iex> Mnemonix.get(store, :foo) :bar

iex> {:ok, store} = Mnemonix.Store.Server.start_link({Mnemonix.Stores.Map, initial: %{foo: :bar}}) iex> Mnemonix.get(store, :foo) :bar

start_link(init, opts)

Starts a new Mnemonix.Store.Server using impl with opts.

The returned GenServer.server/0 reference can be used in the Mnemonix API.

Examples

iex> {:ok, _store} = Mnemonix.Store.Server.start_link(Mnemonix.Stores.Map, name: StoreCache)
iex> Mnemonix.put(StoreCache, :foo, :bar)
iex> Mnemonix.get(StoreCache, :foo)
:bar

iex> {:ok, _store} = Mnemonix.Store.Server.start_link({Mnemonix.Stores.Map, initial: %{foo: :bar}}, name: OtherCache)
iex> Mnemonix.get(OtherCache, :foo)
:bar
terminate(reason, arg2)
terminate(reason, Mnemonix.Store.t) :: reason when reason: :normal | :shutdown | {:shutdown, term} | term

Cleans up the underlying store on termination.

Invokes the c:Mnemonix.Lifecycle.Behaviour.teardown/2 callback.