Skip to content

Latest commit

 

History

History
289 lines (162 loc) · 7.65 KB

rkvs.md

File metadata and controls

289 lines (162 loc) · 7.65 KB

Module rkvs

Data Types


fold_options() = [{start_key, key()} | {end_key, key()} | {gt, key()} | {gte, key()} | {lt, key()} | {lte, key()} | {max, integer()} | {fill_cache, true | false}]

key() = term()

keys() = [key()]

kvs() = [{key(), value()}]

ops_kvs() = [{put, key(), value()} | {delete, key(), value()}]

value() = term()

Function Index

clear/2delete the value associated to the key.
clear_range/4delete all K/Vs in a range.
close/1close a storage.
contains/2is the key exists in the storage.
destroy/1close a storage and remove all the data.
fold/4fold all K/Vs with a function Additionnaly you can pass the following options:
  • 'gt', (greater than), 'gte' (greather than or equal): define the lower bound of the range to fold. Only the records where the key is greater (or equal to) will be given to the function.
  • 'lt' (less than), 'lte' (less than or equal): define the higher bound of the range to fold. Only the records where the key is less than (or equal to) will be given to the function
  • 'start_key', 'end_key', legacy to 'gte', 'lte'
  • 'max' (default=0), the maximum of records to fold before returning the resut
  • 'fill_cache' (default is true): should be the data cached in memory?
fold_keys/4fold all keys with a function same parameters as in the fold function.
get/2get the value associated to the key.
is_empty/1Returns true if this backend contains any values; otherwise returns false.
open/2open a storage, amd pass options to the backend.
put/3store the value associated to the key.
scan/4retrieve a list of Key/Value in a range.
write_batch/2do multiple operations on the backend.

Function Details

clear/2


clear(Engine::engine(), Key::key()) -> ok | {error, term()}

delete the value associated to the key

clear_range/4


clear_range(Engine::engine(), Start::key(), End::key(), Max::integer()) -> ok | {error, term()}

delete all K/Vs in a range

close/1


close(Engine::engine()) -> ok | {error, any()}

close a storage

contains/2


contains(Engine::engine(), Key::key()) -> true | false

is the key exists in the storage

destroy/1


destroy(Engine::engine()) -> ok | {error, any()}

close a storage and remove all the data

fold/4


fold(Engine::engine(), Fun::function(), Acc0::any(), Opts::fold_options()) -> any() | {error, term()}

fold all K/Vs with a function Additionnaly you can pass the following options:

  • 'gt', (greater than), 'gte' (greather than or equal): define the lower bound of the range to fold. Only the records where the key is greater (or equal to) will be given to the function.

  • 'lt' (less than), 'lte' (less than or equal): define the higher bound of the range to fold. Only the records where the key is less than (or equal to) will be given to the function

  • 'start_key', 'end_key', legacy to 'gte', 'lte'

  • 'max' (default=0), the maximum of records to fold before returning the resut

  • 'fill_cache' (default is true): should be the data cached in memory?

fold_keys/4


fold_keys(Engine::engine(), Fun::function(), Acc0::any(), Opts::fold_options()) -> any() | {error, term()}

fold all keys with a function same parameters as in the fold function.

get/2


get(Engine::engine(), Key::key()) -> any() | {error, term()}

get the value associated to the key

is_empty/1


is_empty(Engine::engine()) -> boolean() | {error, term()}

Returns true if this backend contains any values; otherwise returns false.

open/2


open(Name::binary(), Options::list()) -> {ok, engine()} | {error, any()}

open a storage, amd pass options to the backend. The following optinos can be used:

  • 'backend': default is rkvs_ets, folowin backend are provided in rkvs: rkvs_ets, rkvs_leveldb, rkvs_rocksdb, rkvs_hanoidb, rvs_bitcask.

  • 'db_opts': backend options, refers to the backend doc for them

  • 'key_encoding': to encode the key. defautl is raw (binary). can be term, {term, Opts} or sext

  • 'value_encoding': to encode the value. defautl is term. can be term, {term, Opts} or sext

put/3


put(Engine::engine(), Key::key(), Value::value()) -> ok | {error, term()}

store the value associated to the key.

scan/4


scan(Engine::engine(), Start::key(), End::key(), Max::integer()) -> kvs() | {error, term()}

retrieve a list of Key/Value in a range

write_batch/2


write_batch(Engine::engine(), Ops::ops_kvs()) -> ok | {error, term()}

do multiple operations on the backend.