bolt

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package bolt implements a key value store (kv.Store) using bbolt. For more details, see https://github.com/etcd-io/bbolt

Index

Constants

View Source
const Name = "bolt"

Name represents bbolt's shorthand named.

Variables

View Source
var DefaultOptions = &Options{
	Bucket: "default",
	Path:   Name + ".db",
}

DefaultOptions contain's bolts default options.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Buckets are collections of key/value pairs within the database.
	// All keys in a bucket must be unique.
	Bucket string
	// Path is where the database file will be stored.
	Path string
}

Options represents options for configuring the boltdb cache store.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements a the Store interface for bolt. https://godoc.org/github.com/etcd-io/bbolt

func New

func New(o *Options) (*Store, error)

New creates a new bolt cache store. It is up to the operator to make sure that the store's path is writeable.

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close releases all database resources. It will block waiting for any open transactions to finish before closing the database and returning.

func (*Store) Get

func (s *Store) Get(ctx context.Context, k string) (bool, []byte, error)

Get retrieves the value for a key in the bucket. Returns a nil value if the key does not exist or if the key is a nested bucket. The returned value is only valid for the life of the transaction.

func (Store) Set

func (s Store) Set(ctx context.Context, k string, v []byte) error

Set sets the value for a key in the bucket. If the key exist then its previous value will be overwritten. Supplied value must remain valid for the life of the transaction. Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL