This project is an implementation of the Bitcask key-value store in Go, inspired by Coding Challenge #97 by John Crickett from Subsatck Coding Challenges.
Bitcask is a high-performance, append-only key-value store originally developed by Justin Sheehy and David Smith (with inspiration from Eric Brewer). It uses log-structured data files and an in-memory key directory for fast reads and writes, making it simple yet powerful.
This is a learning project to deepen my understanding of storage engines, file I/O, and database internals while practicing Go.
To ensure code quality, there are Git hooks for linting and testing before pushing.
Run this command once to enable the custom hooks:
git config core.hooksPath .githooks
You can interact with the Bitcask database using go run:
Usage: gocask [options] <command> [args]
Options:
--db <path> Path to the database (default "./database")
-h, --help Show this help message
Commands (single-command mode):
set <key> <value> Store a value
get <key> Retrieve a value
del <key> Delete a value
Interactive mode:
Simply run 'gocask' without commands to enter interactive REPL.
Type commands like 'set <key> <value>', 'get <key>' or 'del <key>'.
Use 'exit' or Ctrl+D to quit.
Examples:
gocask set name Sirius --db ./mydb
gocask get name --db ./mydb
gocask # enter interactive modego test ./... -vgolangci-lint runThis project also has a GitHub Actions CI workflow that runs tests and lint checks on every push and pull request to main.
- Basic in-memory
SetandGet -
SetandGetwith file persistence (append-only log) - REPL
- Support for multiple data files
-
Deletefunctionality using tombstones - Merge/compaction functionality to clean up deleted and overwritten keys
- Optional / future enhancements:
- Hint file for faster keydir loading.
- Configurable maximum file size.
- Automatic file rotation.
- Concurrency safety.