storages

Collection of key-value storages adapters for Golang

This project is maintained by reddec

BBolt

API docs

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.

URL initialization

Do not forget to import package!

bbolt://<path>

Where:

Usage

With 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()

Features

Namespaces

Support NamespacedStorage interface.

It allows make nested sub-storages with independent key space.

Example:

aliceStorage := storage.Namespace([]byte("alice"))
bobStorage := storage.Namespace([]byte("bob"))