12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <!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://n2o.dev/blank.css" />
- <link rel="stylesheet" href="https://n2o.dev/zima.css" />
- </head><body><nav>
- <a href="https://n2o.dev">DEV</a>
- <a href="https://kvs.n2o.dev">KVS</a>
- <a href="#" style="background:#ededed;">API</a>
- <div class="dropdown">
- <a onclick="drop()" class="dropbtn">EN</a>
- <div id="dropdown" class="dropdown-content">
- <a href="https://n2o.dev/deps/kvs/man/ua/kvs.htm">UA</a>
- <a href="#">EN</a>
- </div>
- </div>
- </nav><header>
- <a href="../index.html"><img src="https://n2o.dev/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>
- <blockquote>
- <ul><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>
- <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="#dir">dir/0</a></b> — table list.</li>
- </ul></blockquote>
- <p>You can change backend by setting application env.
- This behaves well even under the heavy load.</p>
- </section>
- <section>
- <h3>API</h3>
- <a name="put"></a><p>Data operations.</p>
- <h4>put(tuple()) -> ok | {error,any()}.</h4>
- <a name="get"></a><p>Stores the record.</p>
- <h4>get(atom(),any()) -> {ok,any()} | {error, not_found | duplicated }.</h4>
- <a name="delete"></a><p>Retrieves the record.</p>
- <h4>delete(atom(),any()) -> ok | {error,any()}.</h4>
- <a name="index"></a><p>Deletes the data record.</p>
- <h4>index(atom(),any(),any()) -> list(tuple()).</h4>
- <p>Searches the record by an indexed field and a given value.</p>
- </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>
- <a name="seq"></a><figure><code> -record(id_seq, { thing = atom(),
- id = 0 :: integer() } ).</code></figure>
- <h4>seq(atom(), integer()) -> integer().</h4>
- <a name="count"></a><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>SETUP</h3>
- <p>In <b>sys.config</b> you can specify main kvs backend module as <b>dba</b> parameter
- and list of modules containing <b>metainfo/0</b> exported function. For the
- stream operations you can specify the stream kvs backend module <b>dba_st</b> parameter.</p>
- <a name="dir"></a><figure><code> [{kvs, [{dba,store_mnesia},
- {dba_st,store_stream},
- {schema,[kvs,kvs_stream]}]}].</code></figure>
- <h4>dir() -> list({'table',atom()}).</h4>
- <p>Returns actual tables.</p>
- </section>
- <section>
- <p>This module may refer to:
- <a href="kvs_fs.htm">kvs_fs</a>,
- <a href="kvs_mnesia.htm">kvs_mnesia</a>,
- <a href="kvs_rocks.htm">kvs_rocks</a>,
- <a href="kvs_st.htm">kvs_st</a>,
- <a href="kvs_stream.htm">kvs_stream</a>.
- </p>
- </section>
- </main><footer>
- 2005—2019 © Synrc Research Center
- </footer>
- <script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
- </body></html>
|