Skip to content
Similar to jsonstore, but with boltdb
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
boltstore.go
boltstore_test.go

README.md

boltstore 🏪

GoDoc

boltstore is a Go-library for a simple thread-safe in-memory key-store with persistent BoltDB backend.

Usage

First, install the library using:

go get -u -v github.com/schollz/boltstore

Then you can add it to your program. Check out the examples, or see below for basic usage:

ks := boltstore.Open("mystore.db")

// set a key to any object you want
type Human struct {
  Name   string
  Height float64
}
err := ks.Set("human:1", Human{"Dante", 5.4})
if err != nil {
  panic(err)
}

// get the data back via an interface
var human Human
err = ks2.Get("human:1", &human)
if err != nil {
  panic(err) // returns error if key doesn't exist
}
fmt.Println(human.Name) // Prints 'Dante'

Benchmark

$ go test -bench=.
goos: linux
goarch: amd64
pkg: github.com/schollz/boltstore
BenchmarkGet-4            500000              2474 ns/op
BenchmarkSet-4               300           7375338 ns/op

License

MIT

You can’t perform that action at this time.