bucket

package
v0.0.0-...-9802667 Latest Latest
Warning

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

Go to latest
Published: May 27, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoi

func Btoi(v []byte) uint64

Btoi converts bytes to uint64

func Itob

func Itob(v uint64) []byte

Itob converts uint64 to bytes

Types

type Bucket

type Bucket struct {
	Name []byte
	// contains filtered or unexported fields
}

Bucket used for grouping the key values in boltdb. Also wrap some helper functions.

func New

func New(name []byte, db *bolt.DB) (*Bucket, error)

New create bucket of specific name.

func (*Bucket) Delete

func (b *Bucket) Delete(key []byte) error

Delete removes value of given key

func (*Bucket) DeleteWithTx

func (b *Bucket) DeleteWithTx(tx *bolt.Tx, key []byte) error

DeleteWithTx remove from bucket with tx

func (Bucket) Find

func (b Bucket) Find(filter func(key, value []byte) bool) []byte

Find find value that match the filter in the bucket.

func (*Bucket) ForEach

func (b *Bucket) ForEach(f func(k, v []byte) error) error

ForEach iterate the whole bucket

func (Bucket) Get

func (b Bucket) Get(key []byte) []byte

Get value of specific key in the bucket.

func (*Bucket) GetAll

func (b *Bucket) GetAll() map[interface{}][]byte

GetAll returns all values

func (*Bucket) GetSlice

func (b *Bucket) GetSlice(keys [][]byte) [][]byte

GetSlice returns values by key slice

func (Bucket) GetWithTx

func (b Bucket) GetWithTx(tx *bolt.Tx, key []byte) []byte

GetWithTx gets value

func (*Bucket) IsEmpty

func (b *Bucket) IsEmpty() bool

IsEmpty check if the bucket is empty

func (*Bucket) IsExist

func (b *Bucket) IsExist(k []byte) bool

IsExist check if the value exist of the given key

func (*Bucket) Len

func (b *Bucket) Len() (len int)

Len returns the number of key value pairs

func (Bucket) Put

func (b Bucket) Put(key []byte, value []byte) error

Put key value in the bucket.

func (Bucket) PutWithTx

func (b Bucket) PutWithTx(tx *bolt.Tx, key []byte, value []byte) error

PutWithTx put key value with bolt.Tx

func (*Bucket) RangeUpdate

func (b *Bucket) RangeUpdate(f func(k, v []byte) ([]byte, error)) error

RangeUpdate updates range of the values

func (*Bucket) Reset

func (b *Bucket) Reset() error

Reset resets the bucket

func (*Bucket) Update

func (b *Bucket) Update(key []byte, f func([]byte) ([]byte, error)) error

Update use callback func to update the value of given key

type Rollback

type Rollback func()

Rollback callback function type

type TxHandler

type TxHandler func(tx *bolt.Tx) (Rollback, error)

TxHandler function type for processing bolt transaction

Jump to

Keyboard shortcuts

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