Mnemonix v0.7.0 Mnemonix.Store.Server
Bridges Mnemonix.Features
with underlying Mnemonix.Stores
.
Summary
Types
A two-tuple describing a store type and options to start it
Options used to start a Mnemonix.Store.Server
Functions
Delegates Mnemonix.Feature functions to the underlying store behaviours
Prepares the underlying store impl
for usage with supplied options
Starts a new Mnemonix.Store.Server
using the provided store impl
and options
Starts a new Mnemonix.Store.Server
using store impl
, store
options, and server
options
Cleans up the underlying store on termination
Types
Options used to start a Mnemonix.Store.Server
.
Functions
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.Feature functions to the underlying store behaviours.
init({Mnemonix.Store.Behaviour.t, Mnemonix.Store.options}) :: {:ok, Mnemonix.Store.t} | :ignore | {:stop, reason :: term}
Prepares the underlying store impl
for usage with supplied options
.
Invokes the c:Mnemonix.Core.Behaviour.setup/1
and c:Mnemonix.Expiry.Behaviour.setup_expiry/1
callbacks.
start_link(Mnemonix.Store.Behaviour.t, options) :: GenServer.on_start
Starts a new Mnemonix.Store.Server
using the provided store impl
and options
.
Available options
are:
:store
Options to be given to the store on setup. Study the store
impl
for more information.:server
A keyword list of options to be given to
GenServer
.:otp_app
Fetches more options for the above from
config otp_app, module, options
, and merges them together. If nootp_app
is specified, will check underconfig :mnemonix, module, options
for default options. Options supplied directly to this function always take precedence over any found in your configuration.
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> options = [store: [initial: %{foo: :bar}], server: [name: StoreCache]]
iex> {:ok, _store} = Mnemonix.Store.Server.start_link(Mnemonix.Stores.Map, options)
iex> Mnemonix.get(StoreCache, :foo)
:bar
start_link(Mnemonix.Store.Behaviour.t, Mnemonix.Store.options, GenServer.opts) :: GenServer.on_start
Starts a new Mnemonix.Store.Server
using store impl
, store
options, and server
options.
store
will be given to the store on setup. Study the store impl
for more information.
server
options be given to GenServer.start_link/3
.
No application configuration checking option merging is performed.
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> store = [initial: %{foo: :bar}]
iex> server = [name: StoreCache]
iex> {:ok, _store} = Mnemonix.Store.Server.start_link(Mnemonix.Stores.Map, store, server)
iex> Mnemonix.get(StoreCache, :foo)
:bar