cmd | ||
proto | ||
streampb | ||
tools | ||
_config.yml | ||
.drone.yml | ||
.gitignore | ||
.goreleaser.yml | ||
bitcask_test.go | ||
bitcask.go | ||
CODE_OF_CONDUCT.md | ||
datafile.go | ||
entry.go | ||
go.mod | ||
go.sum | ||
keydir.go | ||
LICENSE | ||
Makefile | ||
README.md | ||
version_test.go | ||
version.go |
bitcask
A Bitcask (LSM+WAL) Key/Value Store written in Go.
Features
- Embeddable
- Builtin CLI
- Builtin Redis-compatible server
- Predictable read/write performance
- Low latecny
- High throughput (See: Performance
Install
$ go get github.com/prologic/bitcask
Usage (library)
Install the package into your project:
$ go get github.com/prologic/bitcask
package main
import (
"log"
"github.com/prologic/bitcask"
)
func main() {
db, _ := bitcask.Open("/tmp/db")
db.Set("Hello", []byte("World"))
db.Close()
}
See the godoc for further documentation and other examples.
Usage (tool)
$ bitcask -p /tmp/db set Hello World
$ bitcask -p /tmp/db get Hello
World
Usage (server)
There is also a builtin very simple Redis-compatible server called bitcaskd
:
$ ./bitcaskd ./tmp
INFO[0000] starting bitcaskd v0.0.7@146f777 bind=":6379" path=./tmp
Example session:
$ telnet localhost 6379
Trying ::1...
Connected to localhost.
Escape character is '^]'.
SET foo bar
+OK
GET foo
$3
bar
DEL foo
:1
GET foo
$-1
PING
+PONG
QUIT
+OK
Connection closed by foreign host.
Performance
Benchmarks run on a 11" Macbook with a 1.4Ghz Intel Core i7:
$ make bench
...
BenchmarkGet-4 300000 5065 ns/op 144 B/op 4 allocs/op
BenchmarkPut-4 100000 14640 ns/op 699 B/op 7 allocs/op
- ~180,000 reads/sec
- ~60,000 writes/sec
License
bitcask is licensed under the MIT License