bboltsimple

package module
v0.0.0-...-81ccdbf Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: MIT Imports: 6 Imported by: 0

README

Simple bbolt

Provides a simpler interface for the key-value store bbolt (https://github.com/etcd-io/bbolt).

Usage

db, _ := bboltsimple.New("/tmp/db")

var value1 myStruct
var value2 myStruct

_ = db.Set("foo", &value1)

_ = db.Get("foo", &value2)

_ = db.Prefix("myPrefix", &myStruct{}, func(key string, value interface{}) error {
	castValue := value.(*myStruct)

  return nil
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB database

func New

func New(path string, bucketName string) (*DB, error)

New creates a new database reference

func (*DB) Close

func (db *DB) Close() error

Close closes a database

func (*DB) Delete

func (db *DB) Delete(key string) error

Delete removes a key from the db

func (*DB) Exist

func (db *DB) Exist(key string) bool

Exist check if a specific key exists

func (*DB) Get

func (db *DB) Get(key string, value interface{}) error

Get load entry for given key

func (*DB) Prefix

func (db *DB) Prefix(prefix string, resultType interface{}, fn func(key string, value interface{}) error) error

Prefix get all entries with given prefix

func (*DB) Set

func (db *DB) Set(key string, value interface{}) error

Set entry for given key

Jump to

Keyboard shortcuts

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