bolt

package
v0.0.0-...-eb64f0e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyPath would be returned when path is "".
	ErrEmptyPath = errors.New("boltdb path required")
	// ErrEmptyBucket would be returned when bucket is "".
	ErrEmptyBucket = errors.New("bucket name required")
)

Functions

This section is empty.

Types

type DB

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

DB equals to bolt.DB

func Open

func Open(path string) (*DB, error)

Open creates and opens a database at the given path. If the file does not exist then it will be created automatically. If path is "", it will return ErrEmptyPath.

func (*DB) Close

func (db *DB) Close() error

Close releases all database resources. All transactions must be closed before closing the database.

func (*DB) Get

func (db *DB) Get(bucket, key []byte) (value []byte, err 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. If bucket is "", it will return ErrEmptyBucket.

func (*DB) Set

func (db *DB) Set(bucket, key, value []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. If bucket is "", it will return ErrEmptyBucket. 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