Wiki

Clone wiki

yatce / Tutorial

Sample Code and little Tutorial

  1. Download and extract ( or, do `hg clone http://bitbucket.org/kuenishi/yatce` )
    1. `make` -> shows usage
    2. `make b` -> builds all source code
    3. `make t` -> regression test
    4. `make c` -> cleans object files
  2. try exec, ebin/tctest.erl 'path/to/yatce.so'
  3. hack it!
simple_test()->
  ok = yatce:start(),
  T = yatce:db('/tmp/tablename.tch', []),
  Key = "somekey",
  Value = "somevalue",
  {ok, opened} = T:open(),
  {ok, inserted} = T:put(Key, Value),
  {ok, Value} = T:get(Key),
  {ok, inserted} = T:put("key2", <<"keyhoge">>),
  {ok, closed} = T:close(),
  yatce:stop().

Basics

  1. Module 'yatce' has application behaviour, so you can start it as a application. the application has no environments, as a formal need it has yatce.app in ebin. currently it doesn't have no running-non-stop upgrade of application is not supported, unless if you say you want it.
  2. Get table 'object' by using yatce:db/2. First argument is the path for TokyoCabinet data file. Second argument is Option list, which directly corresponds to TokyoCabinet table option.
  3. "open" the TokyoCabinet data file. tcadb:open/0 directly calls TokyoCabinet's tcadbopen. Do this once and only once when you start your overall system.
  4. You can do any operations after you opened the 'object'. See API for details. Of course you can touch single 'object' concurrently from multiple processes.
  5. "close" the TokyoCabinet when you stop the system; This calls TokyoCabinet's tcadbclose. Touching table 'object' after the close always fails.
  6. after having all table 'objects' closed, you can stop the yatce by stopping the application.

History / ChangeLogs

See ChangeLog.

Others

See my erlang development diary for fresh information. sorry it's written in Japanese. I'll re-think, if there are much needs for English information, will be written into kuenishi's public English blog.


Sample Code and little Tutorial

  1. ダウンロード、展開 (`hg clone http://bitbucket.org/kuenishi/yatce`とか)
  2. 環境に合わせてMakefileを書き換える
    1. `make` -> shows usage
    2. `make b` -> builds all source code
    3. `make t` -> regression test
    4. `make c` -> cleans object files
  3. ebin/tctest.erlを試しに実行してみるなど
  4. 自分のプログラムを書こう!

History / ChangeLogs

See ChangeLog.


Syntax highlighting

You can also highlight snippets of text, we use the excellent Pygments library.

You can check out the source of this page to see how that's done, and make sure to bookmark the vast library of Pygment lexers, we accept the 'short name' or the 'mimetype' of anything in there.

Have fun!

Updated