Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any API usage docs? #22

Open
maxlapshin opened this issue Jan 25, 2014 · 2 comments
Open

Any API usage docs? #22

maxlapshin opened this issue Jan 25, 2014 · 2 comments

Comments

@maxlapshin
Copy link

Hi. I can't find api docs. Are there any?

How should I write and read data from erlang? Maybe there is some simple usage example?

@marianoguerra
Copy link

👍

@opensam
Copy link

opensam commented Jan 31, 2014

Here is my little 'write and read data from erlang' sheet :

{ok, Tree} = hanoidb:open("mydb.hanoidb").
ok = hanoidb:put(Tree, <<"key1">>, <<"val1">>).
ok = hanoidb:put(Tree, <<"key2">>, <<"val2">>).
{ok,<<"val1">>} = hanoidb:get(Tree, <<"key1">>).
{ok,<<"val2">>} = hanoidb:get(Tree, <<"key2">>).
ok = hanoidb:close(Tree).

After put/get, here is delete (before close obviously) :
ok = hanoidb:delete(Tree, <<"BOO">>),
not_found = hanoidb:get(Tree, <<"BOO">>)

There si also key expiry:
ok = hanoidb:put(Tree, <<"foo">>, <<"bar">>, 2), % 2 sec
{ok, <<"bar">>} = hanoidb:get(Tree, <<"foo">>),
ok = timer:sleep(3000), % 3000 ms
not_found = hanoidb:get(Tree, <<"foo">>)

And the powerfull fold(DB, Fun, Acc)
see also fold_range in the source.

Hope it helps
Have fun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants