CaskDB is a disk-based, embedded, persistent, key-value store based on the Riak's bitcask paper, written in Go. It is more focused on the educational capabilities than using it in production. The file format is platform, machine, and programming language independent. Say, the database file created from Go on macOS should be compatible with Rust on Windows.
This project aims to help anyone, even a beginner in databases, build a persistent database in a few hours. There are no external dependencies; only the Go standard library is enough.
If you are interested in writing the database yourself, head to the workshop section.
Most of the following limitations are of CaskDB. However, there are some due to design constraints by the Bitcask paper.
Consider joining the Discord community to build and learn KV Store with peers.
CaskDB does not require any external libraries to run. Go standard library is enough.
go get github.com/avinassh/go-caskdb
store, _ := NewDiskStore("books.db")
store.Set("othello", "shakespeare")
author := store.Get("othello")
This project is a Go version of the same project in Python.
The workshop is for intermediate-advanced programmers. Knowing basics of Go helps, and you can build the database in any language you wish.
Not sure where you stand? You are ready if you have done the following in any language:
NOTE: I don't have any workshops scheduled shortly. Follow me on Twitter for updates. Drop me an email if you wish to arrange a workshop for your team/company.
CaskDB comes with a full test suite and a wide range of tools to help you write a database quickly. A Github action is present with an automated tests runner. Fork the repo, push the code, and pass the tests!
Throughout the workshop, you will implement the following:
start-here
branchformat_test.go
disk_store_test.go
Run make test
to run the tests locally. Push the code to Github, and tests will run on different OS: ubuntu, mac, and windows.
Not sure how to proceed? Then check the hints file which contains more details on the tasks and hints.
I often get questions about what is next after the basic implementation. Here are some challenges (with different levels of difficulties)
$ tokei -f format.go disk_store.go
===============================================================================
Language Files Lines Code Comments Blanks
===============================================================================
Go 2 320 133 168 19
-------------------------------------------------------------------------------
format.go 111 35 67 9
disk_store.go 209 98 101 10
===============================================================================
Total 2 320 133 168 19
===============================================================================
All contributions are welcome. Please check CONTRIBUTING.md for more details.
Author | Feature | PR |
---|---|---|
PaulisMatrix | Delete Op | #6 |
PaulisMatrix | Checksum | #7 |
The MIT license. Please check LICENSE
for more details.