kvs.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <html>
  2. <head>
  3. <meta charset="utf-8" />
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta name="description" content="" />
  7. <meta name="author" content="Maxim Sokhatsky" />
  8. <title>KVS</title>
  9. <link rel="stylesheet" href="https://synrc.space/synrc.css" />
  10. </head>
  11. <body>
  12. <nav>
  13. <a href='https://synrc.space/'>SYNRC</a>
  14. <a href='https://n2o.space'>N2O</a>
  15. <a href='https://kvs.n2o.space'>KVS</a>
  16. </nav>
  17. <header>
  18. <a href="../index.html"><img src="../Synrc Neo.svg"></a>
  19. <h1>KVS</h1>
  20. </header>
  21. <main>
  22. <section>
  23. <h3>INTRO</h3>
  24. <p>This module is used to manage different KV backends to your cloud of Erlang apps.
  25. This is an unified abstraction layer to several databases: <b>redis</b>,
  26. <b>mongo</b>, <b>mnesia</b>, <b>riak</b>, <b>aerospike</b>.</p>
  27. <p><blockquote><p><ul>
  28. <li><b><a href="#dir">dir/0</a></b> &mdash; table list.</li>
  29. <li><b><a href="#ver">ver/0</a></b> &mdash; KVS version.</li>
  30. <li><b><a href="#seq">seq/2</a></b> &mdash; generate new sequence id for table.</li>
  31. <li><b><a href="#count">count/1</a></b> &mdash; records in table.</li>
  32. <li><b><a href="#put">put/1</a></b> &mdash; put record using element 2 as key.</li>
  33. <li><b><a href="#get">get/2</a></b> &mdash; get record by key from table.</li>
  34. <li><b><a href="#delete">delete/1</a></b> &mdash; delete record from table.</li>
  35. <li><b><a href="#index">index/3</a></b> &mdash; index by field and its value.</li>
  36. </ul></p></blockquote></p>
  37. <p>You can change backend by setting application env. This behaves well on </p>
  38. <figure><code>
  39. application:set_env(kvs,dba,store_mnesia).
  40. </code></figure>
  41. </section>
  42. <section>
  43. <h3>RECORDS</h3>
  44. <figure><figcaption>KVS CORE</figcaption><code>
  45. #ok { data= [] :: term() }.
  46. #error { data= [] :: term() }.
  47. #cur { id= [] :: term(),
  48. top= [] :: [] | integer(),
  49. bot= [] :: [] | integer(),
  50. dir= 0 :: 0 | 1,
  51. reader= [] :: [] | tuple(),
  52. writer= [] :: [] | tuple(),
  53. left= 0 :: integer(),
  54. right= 0 :: inetegr() }.
  55. #iter { id= [] :: [] | integer(),
  56. prev= [] :: [] | integer(),
  57. next= [] :: [] | integer()).
  58. </code></figure>
  59. <p><ul>
  60. <li>id &mdash; Unique key of the cursor.</li>
  61. </ul></p>
  62. </section>
  63. <section>
  64. <h3>CONFIG</h3>
  65. <p>In sys.config you should specify kvs backend and list of modules
  66. containing <b>metainfo/0</b> exported function.</p>
  67. <figure><code>
  68. [{kvs, [{dba, store_mnesia},
  69. {schema, [kvs]} ]}].
  70. </code></figure>
  71. </section>
  72. <section>
  73. <p>This module may refer to:
  74. <a href="http://erlang.org/doc/man/mnesia.html">mnesia</a></b>,
  75. <a href="kvs_stream.htm"><b>kvs_stream</b></a>.
  76. </p>
  77. </section>
  78. </main>
  79. <footer>
  80. 2005&mdash;2017 &copy; Synrc Research Center
  81. </footer>
  82. </body>
  83. </html>