KVS module provides user level interface for console commands. It has discovery, data manipulation and retrival features. Under the hood it handles configurable run-time backends for each supported database.

  • dir/0 — table list.
  • ver/0 — KVS version.
  • seq/2 — generate new sequence table id.
  • count/1 — counts records in table.
  • put/1 — put record using id as a key.
  • get/2 — get record by key from table.
  • delete/1 — delete record from table.
  • index/3 — search records by field and its value.

You can change backend by setting application env. This behaves well even under the heavy load.


In sys.config you should specify kvs backend and list of modules containing metainfo/0 exported function.

[{kvs, [{dba,store_mnesia}, {schema,[kvs,kvs_stream]}]}].

dir() -> list({'table',atom()}).

Returns actual tables.

ver() -> {'version',string()}.

Returns backend version.

dump() -> ok.

Display database information.

> kvs:dump(). NAME STORAGE TYPE MEMORY (MB) ELEMENTS id_seq disc_copies 0.00 0 writer disc_copies 0.00 0 emails disc_copies 0.00 0 reader disc_copies 0.00 0 Snapshot taken: {{2018,11,10},{5,2,38}} ok


Sequence table id_seq stores the counter per thing. The couners are global and atomic in each supported database. Sequences are used to generate unique names for records per distributed table. If names in the table are not unique, e.g. then count function may return a different value than the current sequence.

-record(id_seq, { thing = atom(), id = 0 :: integer() } ).

seq(atom(), integer()) -> integer().

Increments and returns id counter for the particular table.

count(atom()) -> integer().

Returns number of records in table.


Data operations.

put(tuple()) -> ok | {error,any()}.

Storing of data record.

get(atom(),any()) -> {ok,any()} | {error, not_found | duplicated }.

Retrival of data record.

delete(atom(),any()) -> ok | {error,any()}.

Deletion of data record.

index(atom(),any(),any()) -> list(tuple()).

Search of data record by an indexed field and a given value.

This module may refer to: kvs_stream.