Go to file
2019-03-22 17:59:07 +10:00
cmd Add KeYS command to server (bitraftd) 2019-03-21 10:49:53 +10:00
internal Refactor Datafile.Size() 2019-03-22 17:33:24 +10:00
tools Revert "Fixed release script so go mod is happy" 2019-03-13 06:41:03 +10:00
_config.yml Set theme jekyll-theme-hacker 2019-03-13 00:06:31 +10:00
.drone.yml Remove notify step for now 2019-03-20 07:08:10 +10:00
.gitignore Add a simple Redis compatible server daemon (bitcaskd) 2019-03-13 21:19:46 +10:00
.goreleaser.yml Fixed injecting Version/Commit in relased binaries 2019-03-19 18:55:03 +10:00
bitcask_test.go Add Len() to exported API (extended API) 2019-03-21 10:47:50 +10:00
bitcask.go Fixed concurrency bug with reopening datafiles when maxDatafileSize is exceeded 2019-03-22 17:59:07 +10:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2019-03-13 06:45:43 +10:00
go.mod Updated deps 2019-03-18 19:47:08 +10:00
go.sum Updated deps 2019-03-18 19:47:08 +10:00
LICENSE Create LICENSE 2019-03-13 06:46:32 +10:00
Makefile Add bitcaskd to install target 2019-03-20 07:00:46 +10:00
options.go Add docs for options 2019-03-21 17:20:53 +10:00
README.md Update README.md 2019-03-21 08:36:17 +10:00

bitcask

Build Status CodeCov Go Report Card GoDoc Sourcegraph

A high performance Key/Value store written in Go with a predictable read/write performance and high throughput. Uses a Bitcask on-disk layout (LSM+WAL) similar to Riak.

Features

  • Embeddable (import "github.com/prologic/bitcask")
  • Builtin CLI (bitcask)
  • Builtin Redis-compatible server (bitcaskd)
  • 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 "github.com/prologic/bitcask"

func main() {
    db, _ := bitcask.Open("/tmp/db")
    defer db.Close()
    db.Set("Hello", []byte("World"))
    val, _ := db.Get("hello")
}

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/128B-4         	  300000	      5178 ns/op	     400 B/op	       5 allocs/op
BenchmarkGet/256B-4         	  300000	      5273 ns/op	     656 B/op	       5 allocs/op
BenchmarkGet/512B-4         	  200000	      5368 ns/op	    1200 B/op	       5 allocs/op
BenchmarkGet/1K-4           	  200000	      5800 ns/op	    2288 B/op	       5 allocs/op
BenchmarkGet/2K-4           	  200000	      6766 ns/op	    4464 B/op	       5 allocs/op
BenchmarkGet/4K-4           	  200000	      7857 ns/op	    9072 B/op	       5 allocs/op
BenchmarkGet/8K-4           	  200000	      9538 ns/op	   17776 B/op	       5 allocs/op
BenchmarkGet/16K-4          	  100000	     13188 ns/op	   34928 B/op	       5 allocs/op
BenchmarkGet/32K-4          	  100000	     21620 ns/op	   73840 B/op	       5 allocs/op

BenchmarkPut/128B-4         	  200000	      7875 ns/op	     409 B/op	       6 allocs/op
BenchmarkPut/256B-4         	  200000	      8712 ns/op	     538 B/op	       6 allocs/op
BenchmarkPut/512B-4         	  200000	      9832 ns/op	     829 B/op	       6 allocs/op
BenchmarkPut/1K-4           	  100000	     13105 ns/op	    1410 B/op	       6 allocs/op
BenchmarkPut/2K-4           	  100000	     18601 ns/op	    2572 B/op	       6 allocs/op
BenchmarkPut/4K-4           	   50000	     36631 ns/op	    5151 B/op	       6 allocs/op
BenchmarkPut/8K-4           	   30000	     56128 ns/op	    9798 B/op	       6 allocs/op
BenchmarkPut/16K-4          	   20000	     83209 ns/op	   18834 B/op	       6 allocs/op
BenchmarkPut/32K-4          	   10000	    135899 ns/op	   41517 B/op	       6 allocs/op

BenchmarkScan-4             	 1000000	      1851 ns/op	     493 B/op	      25 allocs/op

For 128B values:

  • ~200,000 reads/sec
  • ~130,000 writes/sec

The full benchmark above shows linear performance as you increase key/value sizes.

License

bitcask is licensed under the MIT License