bitdb

module
v0.0.0-...-17dc2c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2025 License: MIT

README

BitDB

build codecov

BitDB is a lightweight key/value store written in Go. It is a toy project that I worked on while learning Go. It follows a Bitcask style architecture:

  • Append-only segments – all writes are appended to the active segment file. Older segments become read-only.
  • In-memory index – keys are mapped to the segment and byte offset of their latest value for fast reads.
  • Background merging – old segments can be compacted into new ones to drop obsolete values and reclaim space.

Running

Run the server with go run and point it at a data directory:

go run ./cmd/server -path ./data

Then use the client to set and get keys:

go run ./cmd/client set foo bar
go run ./cmd/client get foo

Testing

To run tests:

just test

Test with race detector enabled:

just testrace

I run tests with race detector by default now.

Linting

For lint, we use golangci-lint tool. Run with:

just lint

Benchmarking/profiling

Results are on BENCHMARKS.md

I'm not doing these on my Mac so I don't wear down my ssd.

Run on hetzner or somewhere else(remember to change TMPDIR as written in justfile)

# Run all benchmarks
just bench

Profiling works by running benchmarks and opening a server. After running the profiler, just go to $HOST:1730

# Profile Set
just profile Benchmark_Set

Directories

Path Synopsis
cmd
client command
remote
Package remote provides an RPC wrapper around the core DB.
Package remote provides an RPC wrapper around the core DB.
server command
Package core provides the core BitDB implementation.
Package core provides the core BitDB implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL