bolt

package module
v0.0.0-...-e54589a Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

README

bolt

a API wrapper for boltdb that simpler and easier to use.

install

$ go get gitee.com/shupkg/bolt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBucketNotFound          = bbolt.ErrBucketNotFound
	ErrKeyNotFound             = errors.New("key not found")
	DefaultOptions    *Options = bbolt.DefaultOptions
)
View Source
var (
	ErrWalkExit  = errors.New("walk exit")
	ErrSkipChild = errors.New("skip bucket child")
	ErrSkipKey   = errors.New("skip key")
)

Functions

func Walk

func Walk(tx Tx, walk FilterFunc) error

Types

type Cursor

type Cursor = bbolt.Cursor

type DB

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

DB wrap for boltdb, combo tx and bucket

func Open

func Open(path string, mode os.FileMode, options ...*Options) (*DB, error)

func OpenDefault

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

func With

func With(bdb *boltDB) *DB

func (*DB) Batch

func (db *DB) Batch(txFunc TxFunc) (err error)

func (*DB) Begin

func (db *DB) Begin(writable bool) (Tx, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) DB

func (db *DB) DB() *boltDB

func (*DB) Update

func (db *DB) Update(txFunc TxFunc) (err error)

func (*DB) View

func (db *DB) View(txFunc TxFunc) (err error)

type EntrySet

type EntrySet []entry

func List

func List(tx Tx, listOptions ...ListOption) (set EntrySet, err error)

func (*EntrySet) Add

func (es *EntrySet) Add(k, v []byte, b Tx)

func (*EntrySet) Array

func (es *EntrySet) Array() []entry

func (*EntrySet) Insert

func (es *EntrySet) Insert(pos int, k, v []byte, b Tx)

func (EntrySet) Len

func (es EntrySet) Len() int

func (EntrySet) Less

func (es EntrySet) Less(i, j int) bool

func (*EntrySet) RemoveAt

func (es *EntrySet) RemoveAt(pos int)

func (EntrySet) Sort

func (es EntrySet) Sort()

func (EntrySet) Swap

func (es EntrySet) Swap(i, j int)

type FilterFunc

type FilterFunc = func(k, v []byte, bucket Tx) error

type ListOption

type ListOption func(options *ListOptions)

func ListFilter

func ListFilter(filter FilterFunc) ListOption

func ListNoBucket

func ListNoBucket() ListOption

func ListOnlyBucket

func ListOnlyBucket() ListOption

func ListReverse

func ListReverse() ListOption

func ListSeek

func ListSeek(prefix []byte) ListOption

type ListOptions

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

func (*ListOptions) Apply

func (o *ListOptions) Apply(options ...ListOption) *ListOptions

func (*ListOptions) Filter

func (o *ListOptions) Filter(k, v []byte, b Tx) error

type Options

type Options = bbolt.Options

type Tx

type Tx interface {
	Root() Tx
	Parent() Tx
	Pwd() [][]byte
	IsRoot() bool
	Writable() bool

	Bucket(name []byte) Tx
	CreateBucket(name []byte) (Tx, error)
	DeleteBucket(name []byte) error

	Get(key []byte) []byte
	Put(key []byte, value []byte) error
	Delete(key []byte) error

	Cursor() *Cursor
	Walk(walk FilterFunc) error
	List(listOptions ...ListOption) (EntrySet, error)

	NextSequence() (uint64, error)
	Sequence() uint64
	SetSequence(v uint64) error

	Stats() interface{}
	DB() *DB
}

type TxFunc

type TxFunc func(tx Tx) error

Jump to

Keyboard shortcuts

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