Documentation ¶
Overview ¶
Package bbolt contains an implementation of the `gokv.Store` interface for bbolt (formerly known as Bolt / Bolt DB).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ BucketName: "default", Path: "bbolt.db", Codec: encoding.JSON, }
DefaultOptions is an Options object with default values. BucketName: "default", Path: "bbolt.db", Codec: encoding.JSON
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // Bucket name for storing the key-value pairs. // Optional ("default" by default). BucketName string // Path of the DB file. // Optional ("bbolt.db" by default). Path string // Encoding format. // Optional (encoding.JSON by default). Codec encoding.Codec }
Options are the options for the bbolt store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a gokv.Store implementation for bbolt (formerly known as Bolt / Bolt DB).
func NewStore ¶
NewStore creates a new bbolt store. Note: bbolt uses an exclusive write lock on the database file so it cannot be shared by multiple processes. So when creating multiple clients you should always use a new database file (by setting a different Path in the options).
You must call the Close() method on the store when you're done working with it.
func (Store) Close ¶
Close closes the store. It must be called to make sure that all open transactions finish and to release all DB resources.
func (Store) Delete ¶
Delete deletes the stored value for the given key. Deleting a non-existing key-value pair does NOT lead to an error. The key must not be "".
func (Store) Get ¶
Get retrieves the stored value for the given key. You need to pass a pointer to the value, so in case of a struct the automatic unmarshalling can populate the fields of the object that v points to with the values of the retrieved object's values. If no value is found it returns (false, nil). The key must not be "" and the pointer must not be nil.