Collection of key-value storages adapters for Golang
This project is maintained by reddec
github.com/reddec/storages/std/boltdb
Generates BoltDB (etc.d fork called bbolt) storage.
Default bucket name is DEFAULT
.
Uses buckets as namespaces. Closing root (parent) storage will close all namespaced storages but not vice-versa.
Do not forget to import package!
bbolt://<path>
Where:
<path>
- path storage fileWith default bucket
storage, err := boltdb.NewDefault("path/to/file")
if err != nil {
panic(err)
}
defer storage.Close()
With custom bucket
storage, err := boltdb.New("path/to/file", []byte("custom bucket name"))
if err != nil {
panic(err)
}
defer storage.Close()
Support NamespacedStorage interface.
It allows make nested sub-storages with independent key space.
Example:
aliceStorage := storage.Namespace([]byte("alice"))
bobStorage := storage.Namespace([]byte("bob"))