View Source Minikv.Kvs (minikv v0.1.1)
A supervisor for Minikv, providing a key-value store.
Summary
Functions
A macro to use the KVS in a module.
Returns a specification to start this module under a supervisor.
Deletes a value from the KVS.
Retrieves a value from the KVS.
Callback implementation for Supervisor.init/1
.
Lock a key in the registry.
Persist a key value in the registry.
Puts a value into the KVS.
Puts a value into the KVS.
Unlock a key in the registry.
Types
@type kv() :: Minikv.Kv.t()
Functions
A macro to use the KVS in a module.
Example
defmodule MyExampleKvs do
use Minikv.Kvs
end
Returns a specification to start this module under a supervisor.
See Supervisor
.
Deletes a value from the KVS.
Example
iex> Minikv.Kvs.delete(:my_kvs, "my_key")
:ok
Retrieves a value from the KVS.
Example
iex> Minikv.Kvs.get(:my_kvs, "my_key")
%Kv{value: "my_value", node: :node1, time: 123456789}
Callback implementation for Supervisor.init/1
.
Lock a key in the registry.
Example
iex> {:ok, registry} = Minikv.Kvs.start_link(name: :my_registry)
iex> Minikv.Kvs.lock(registry, "my_key")
:ok
Persist a key value in the registry.
Example
iex> {:ok, registry} = Minikv.Kvs.start_link(name: :my_registry)
iex> Minikv.Kvs.delete(registry, "my_key")
:ok
Puts a value into the KVS.
Example
iex> Minikv.Kvs.put(:my_kvs, "my_key", "my_value")
:ok
Puts a value into the KVS.
Example
iex> Minikv.Kvs.set(:my_kvs, "my_key", "my_value")
:ok
Unlock a key in the registry.
Example
iex> {:ok, registry} = Minikv.Kvs.start_link(name: :my_registry)
iex> Minikv.Kvs.lock(registry, "my_key")
:ok
iex> Minikv.Kvs.unlock(registry, "my_key")
:ok