package cdb

All checked builds pass
  1. Overview
  2. Docs
CDB implementation in OCaml

Install

dune-project
 Dependency

Authors

Maintainers

Sources

1.0.1.tar.gz
md5=deb487b574cf1a925424b410627a9e05
sha512=fedf279196fa894e7a7fdc47ccc05ad7b32e6e98a2ad51281aab78a3715de42a46efbc2c34861d0df8f5f0280ca5ff3520516bc648dfbc32e3db0c2161507dc7

Description

CDB (Constant Database) is a fast, reliable, simple package for creating and reading constant databases.

Added to opam-repository:

README

This is Dustin Sallings OCaml CDB library, pulled from the 2007 wayback machine.

It has been updated to work with OCaml 5.2.0 by Jesse.

What is CDB?

CDB is a simple and elegant constant database. Think of it as an associative array on disk. Reads are fast, but writes are slow because the whole file needs to be rebuilt for every change.

It comes from a time when CPUs were much slower, disks were much smaller, and being clever about how you use resources mattered much more. Today, SQLite and/or JSON are probably better choices in most situations.

Further reading:

  1. https://cr.yp.to/cdb/cdb.txt and https://cr.yp.to/cdb.html
  2. http://www.cse.yorku.ca/~oz/hash.html
  3. https://www.unixuser.org/~euske/doc/cdbinternals/index.html

Getting Started

opam install cdb

Read a value

(* Open the CDB for searching *)
let cdb_file = Cdb.open_cdb_in "my_cdb.cdb" in

(* Get matches for a key *)
let matches = Cdb.get_matches cdb_file "key1" in

(* Iterate over the matches and print them *)
Seq.iter (fun value -> print_endline ("Found value: " ^ value)) matches;

(* Close the CDB file *)
Cdb.close_cdb_in cdb_file

Writing values

(* Create and populate a CDB *)
let creator = Cdb.open_out "my_cdb.cdb" in
Cdb.add creator "key1" "value1";
Cdb.add creator "key2" "value2";
Cdb.close_cdb_out creator;

Contributor

dune build

Test

dune exec ./test/main.exe

Dependencies (2)

  1. dune >= "2.0"
  2. ocaml >= "5.00.0"

Dev Dependencies

None

Optional Dependencies

None

Used by

None

Conflicts

None

Build status

Results of building cdb with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
1.0.1 (this version) n/a n/a good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure