123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="description" content="" />
- <meta name="author" content="Maxim Sokhatsky" />
- <title>KVS</title>
- <link rel="stylesheet" href="https://synrc.space/synrc.css" />
- </head>
- <body>
- <nav>
- <a href='https://n2o.dev'>DEV</a>
- <a href='https://kvx.n2o.space'>KVS</a>
- <a href='#' style="background:#ededed;">KVS</a>
- </nav>
- <header>
- <a href="../index.html"><img src="https://n2o.space/img/Synrc Neo.svg"></a>
- <h1>KVS</h1>
- </header>
- <main>
- <section>
- <h3>INTRO</h3>
- <p>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.</p>
- <p><blockquote><p><ul>
- <li><b><a href="#dir">dir/0</a></b> — table list.</li>
- <li><b><a href="#ver">ver/0</a></b> — KVS version.</li>
- <li><b><a href="#seq">seq/2</a></b> — generate new sequence table id.</li>
- <li><b><a href="#count">count/1</a></b> — counts records in table.</li>
- <li><b><a href="#put">put/1</a></b> — put record using id as a key.</li>
- <li><b><a href="#get">get/2</a></b> — get record by key from table.</li>
- <li><b><a href="#delete">delete/1</a></b> — delete record from table.</li>
- <li><b><a href="#index">index/3</a></b> — search records by field and its value.</li>
- </ul></p></blockquote></p>
- <p>You can change backend by setting application env.
- This behaves well even under the heavy load.</p>
- </section>
- <section>
- <h3>SETUP</h3>
- <p>In sys.config you should specify kvx backend and list of modules
- containing <b>metainfo/0</b> exported function.</p>
- <figure><code>
- [{kvx, [{dba,store_mnesia},
- {schema,[kvx,kvx_stream]}]}].
- </code></figure>
- <h4>dir() -> list({'table',atom()}).</h4>
- <p>Returns actual tables.</p>
- <h4>ver() -> {'version',string()}.</h4>
- <p>Returns backend version.</p>
- <h4>dump() -> ok.</h4>
- <p>Display database information.</p>
- <figure><code>
- > kvx: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
- </code></figure>
- </section>
- <section>
- <h3>SEQ</h3>
- <p>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.
- </p>
- <figure><code>
- -record(id_seq, { thing = atom(),
- id = 0 :: integer() } ).
- </code></figure>
- <h4>seq(atom(), integer()) -> integer().</h4>
- <p>Increments and returns id counter for the particular table.</p>
- <h4>count(atom()) -> integer().</h4>
- <p>Returns number of records in table.</p>
- </section>
- <section>
- <h3>BACKEND</h3>
- <p>Data operations.
- </p>
- <h4>put(tuple()) -> ok | {error,any()}.</h4>
- <p>Storing of data record.</p>
- <h4>get(atom(),any()) -> {ok,any()} | {error, not_found | duplicated }.</h4>
- <p>Retrieval of data record.</p>
- <h4>delete(atom(),any()) -> ok | {error,any()}.</h4>
- <p>Deletion of data record.</p>
- <h4>index(atom(),any(),any()) -> list(tuple()).</h4>
- <p>Search of data record by an indexed field and a given value.</p>
- </section>
- <section>
- <p>This module may refer to:
- <a href="kvx_fs.htm"><b>kvx_fs</b></a>,
- <a href="kvx_mnesia.htm"><b>kvx_mnesia</b></a>,
- <a href="kvx_rocks.htm"><b>kvx_rocks</b></a>,
- <a href="kvx_st.htm"><b>kvx_st</b></a>,
- <a href="kvx_stream.htm"><b>kvx_stream</b></a>.
- </p>
- </section>
- </main>
- <footer>
- 2005—2019 © Synrc Research Center
- </footer>
- </body>
- </html>
|