OCaml Bitcask

Bitcask is a local key value store. It can be used as an hashtable persisted to disk. It has the following features:

Bitcask was originally developed by Basho Technologies as a storage component for the Riak distributed database.

The original implementation is written in Erlang. Since the concepts behind Bitcask are fairly easy, several implementations appeared for various languages.

This implementation allows you to operate on bitcask stores from OCaml while being compatible with the original Erlang implementation.

Getting started

Make sure that you have ocaml, findlib and bitcask installed. The # character represent the toploop prompt.

Load the toploop and the bitcask package:

$ ocaml
        Objective Caml version 3.12.0

# #use "topfind";;
# #require "bitcask";;

Bitcask stores can be loaded using the Bitcask.load function:

# let bitcask = Bitcask.load "/path/to/store";;

Stores should be closed with Bitcask.close:

# Bitcask.close bitcask;;

By default, the Bitcask.load function will open stores in a read-only mode. If you plan to modify the store, you should open the store in read-write mode:

# let bitcask = Bitcask.load ~mode:BitcaskOption.Read_write "/path/to/store";;

You could then insert some data using Bitcask.put

# Bitcask.put bitcask "key" "value";;

You could test whether a store contains a particular key with Bitcask.contains:

# Bitcask.contains bitcask "key";;

Values can be retrieved with Bitcask.get or Bitcask.get_exn:

# let value_option = Bitcask.get bitcask "key";;

This covers the basic usage of bitcask stores. Please refer to the API documentation for further information.

API Documentation

local key value store
bitcask setting management

Author(s): Jonathan Derque