#key-value-store #bitcask #log #database #log-level #ok #datadir

nightly bin+lib bitrust

A Rust implementation of Bitcask, usable as a binary or a library

1 unstable release

Uses old Rust 2015

0.1.0 May 13, 2021

#270 in Database implementations

Custom license

105KB
2.5K SLoC

Bitrust

This is a Rust implementation of Bitcask, a persistent key-value store for when the keyspace fits in memory. This is not a distributed datastore, but can be used as a building block for one.

This crate hasn't been stress-tested. While it should be good enough for experimentation, we make no guarantees around data durability.

Running

$ mkdir /tmp/bitrust_data
$ cargo run -- --configfile ./example_configs/no-automerge.toml --loglevel debug
> put foo bar
> get foo
Ok(Some("bar"))
> put baz spam
> put lala baba
> put baz egg
> lst
lala
foo
baz
> get baz
Ok(Some("egg"))
> quit 
$ less /tmp/bitrust_data/bitrust.log

You can view the logs in a separate window by tailing bitrust.log in the datadir.

$ tail -f /tmp/bitrust_data/bitrust.log

Data directory contents

  • Data files are stored as N.data where N is an integer starting at 0.
  • .activefile contains the name of the current "active" log file (i.e., the one taking writes). All other datafiles are immutable.
  • bitrust.log contains logs. Level of logging is controlled by the -l/--loglevel switch.

Dependencies

~14–26MB
~415K SLoC