Module Rocksdb

A binding to RocksDB

This library is a binding to Facebook's RocksDB library. This library attempts to provide a layer on top of Rock's C FFI adapting it as much as possible to OCaml idioms. It aims to cover most of the C FFI in the long run, along with tests to ensure no function is left never called and untested.

type error = [
| `Msg of string
]
module Options : sig ... end
type t

Opaque database handle

val open_db : config:Options.config -> name:string -> (terror) Stdlib.result

open_db options name will return an handle to the database in case of success or the error returned by RocksDB in case of failure. name is the path to the database.

val open_db_read_only : ?⁠fail_on_wal:bool -> config:Options.config -> name:string -> (terror) Stdlib.result

open_db options name will return a read-only handle to the database in case of success or the error returned by RocksDB in case of failure. name is the path to the database. fail_on_wal returns an error if write log is not empty

val open_db_with_ttl : config:Options.config -> name:string -> ttl:int -> (terror) Stdlib.result

open_db_with_ttl options name ttl will return an handle to the database in case of success or the error returned by RocksDB in case of failure. name is the path to the database. ttl Time in seconds after which a key should be removed (best-effort basis, during compaction)

val put : t -> Options.Write_options.t -> key:string -> value:string -> (unit, error) Stdlib.result

put db write_options key value will write at key key the value value, on database db. Return unit on success, RocksDB reported error on error.

val delete : t -> Options.Write_options.t -> string -> (unit, error) Stdlib.result

delete db write_options key will delete key key on database db. Return unit on success, RocksDB reported error on error.

val get : t -> Options.Read_options.t -> string -> ([ `Not_found | `Found of string ]error) Stdlib.result

get db read_options key will fetch key key on database db. Returns `Ok value if the key is found, `Not_found otherwise, and `Error if a failure occurred.

val flush : t -> Options.Flush_options.t -> (unit, error) Stdlib.result

flush db flush_options will flush all pending memtables on database db. Return unit on success, RocksDB reported error on error.

val compact_now : t -> (unit, error) Stdlib.result

compact_now db will initiate a compaction on all ranges available in database. This is an asynchronous operation, returning unit once operation is started.

val stats : t -> (string optionerror) Stdlib.result

stats db will return the accumulated stats for this database handle as an optional string form

val get_cache_usage : t -> (int, error) Stdlib.result
val close_db : t -> (unit, error) Stdlib.result

close db explicitly closes the db handle. Any further access will raise an error

module Batch : sig ... end

Batch processing RocksDB allows to batch operations through a dedicated batch object that must be fed to write. A batch object Batch.batch is a collection of operation to run on a database. (like Batch.put or delete).

module Iterator : sig ... end
module Perf_context : sig ... end