barrel_store behaviour (barrel_docdb v1.0.0)

View Source

Storage behaviour for barrel_docdb

Defines the interface for storage backends. The default implementation uses RocksDB (barrel_store_rocksdb).

Summary

Functions

Get the configured storage backend module

Callbacks

close/1

-callback close(DbRef :: term()) -> ok.

delete/2

-callback delete(DbRef :: term(), Key :: binary()) -> ok | {error, term()}.

fold/4

-callback fold(DbRef :: term(), Prefix :: binary(), Fun :: fun(), Acc :: term()) -> term().

fold_range/5

-callback fold_range(DbRef :: term(), StartKey :: binary(), EndKey :: binary(), Fun :: fun(), Acc :: term()) ->
                        term().

get/2

-callback get(DbRef :: term(), Key :: binary()) -> {ok, binary()} | not_found | {error, term()}.

open/2

-callback open(Path :: string(), Options :: map()) -> {ok, DbRef :: term()} | {error, term()}.

put/3

-callback put(DbRef :: term(), Key :: binary(), Value :: binary()) -> ok | {error, term()}.

put/4

-callback put(DbRef :: term(), Key :: binary(), Value :: binary(), Options :: list()) ->
                 ok | {error, term()}.

write_batch/2

-callback write_batch(DbRef :: term(), Operations :: list()) -> ok | {error, term()}.

Functions

get_backend()

-spec get_backend() -> module().

Get the configured storage backend module