... | @@ -11,7 +11,7 @@ To run tests run 'rebar3 eunit'. To generate doc, run 'rebar3 edoc'. |
... | @@ -11,7 +11,7 @@ To run tests run 'rebar3 eunit'. To generate doc, run 'rebar3 edoc'. |
|
Or add it to your rebar config
|
|
Or add it to your rebar config
|
|
|
|
|
|
|
|
|
|
```
|
|
```erlang
|
|
{deps, [
|
|
{deps, [
|
|
....
|
|
....
|
|
{rocksdb, {rocksdb, "0.10.0"}}
|
|
{rocksdb, {rocksdb, "0.10.0"}}
|
... | @@ -56,7 +56,7 @@ ok = rocksdb:close(DB). |
... | @@ -56,7 +56,7 @@ ok = rocksdb:close(DB). |
|
|
|
|
|
The library provides put, delete, and get methods to modify/query the database. For example, the following code moves the value stored under key1 to key2.
|
|
The library provides put, delete, and get methods to modify/query the database. For example, the following code moves the value stored under key1 to key2.
|
|
|
|
|
|
```
|
|
```erlang
|
|
rocksdb:put(Db, <<"my key">>, <<"my value">>),
|
|
rocksdb:put(Db, <<"my key">>, <<"my value">>),
|
|
case rocksdb:get(Db, <<"my key">>, []) of
|
|
case rocksdb:get(Db, <<"my key">>, []) of
|
|
{ok, Value} => io:format("retrieved value %p~n", [Value]);
|
|
{ok, Value} => io:format("retrieved value %p~n", [Value]);
|
... | @@ -70,7 +70,7 @@ rocksdb:delete(Db, <<"my key">>). |
... | @@ -70,7 +70,7 @@ rocksdb:delete(Db, <<"my key">>). |
|
|
|
|
|
Note that if the process dies after the Put of key2 but before the delete of key1, the same value may be left stored under multiple keys. Such problems can be avoided by using the function `rocksdb:write/3` class to atomically apply a set of updates:
|
|
Note that if the process dies after the Put of key2 but before the delete of key1, the same value may be left stored under multiple keys. Such problems can be avoided by using the function `rocksdb:write/3` class to atomically apply a set of updates:
|
|
|
|
|
|
```
|
|
```erlang
|
|
Batch = [
|
|
Batch = [
|
|
{put, <<"key1">>, <<"value1">>},
|
|
{put, <<"key1">>, <<"value1">>},
|
|
{delete, <<"keytodelete">>},
|
|
{delete, <<"keytodelete">>},
|
... | @@ -108,4 +108,3 @@ then you can move to the previous or next data using the function `iterator:move |
... | @@ -108,4 +108,3 @@ then you can move to the previous or next data using the function `iterator:move |
|
* move to the previous key of: `rocksdb:iterator_move(Itr,{seek_for_prev, Key})`
|
|
* move to the previous key of: `rocksdb:iterator_move(Itr,{seek_for_prev, Key})`
|
|
|
|
|
|
> An iterator doesn't support parallel operations, so make sure to use it accordingly. |
|
> An iterator doesn't support parallel operations, so make sure to use it accordingly. |
|
|
|
|