bcdb

package
v0.0.0-...-817062f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrement

func Decrement(tx Tx, k []byte) (uint64, error)

func DoRet1

func DoRet1[T any](ctx context.Context, db DB, isWrite bool, fn func(tx Tx) (T, error)) (T, error)

DoRet1 is a convenience function for performing a transaction and returning 1 value

func DoRet2

func DoRet2[A, B any](ctx context.Context, db DB, isWrite bool, fn func(tx Tx) (A, B, error)) (A, B, error)

DoRet2 is a convenience function for performing a transaction and returning 2 values

func Increment

func Increment(tx Tx, k []byte) (uint64, error)

Increment increments and returns a 64 bit integer stored at k. An empty value is interpretted as 0. Increment returns the value after the increment, so it is suitable for reference counts.

func PrefixEnd

func PrefixEnd(prefix []byte) []byte

PrefixEnd return the key > all the keys with prefix p, but < any other key

Types

type Badger

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

func (Badger) Update

func (db Badger) Update(_ context.Context, fn func(Tx) error) error

func (Badger) View

func (db Badger) View(_ context.Context, fn func(Tx) error) error

type DB

type DB interface {
	Update(context.Context, func(Tx) error) error
	View(context.Context, func(Tx) error) error
}

func NewBadger

func NewBadger(dir string) (DB, error)

func NewBadgerMemory

func NewBadgerMemory() DB

func NewPrefixed

func NewPrefixed(db DB, prefix string) DB

type Tx

type Tx interface {
	Put(key, value []byte) error
	Get(key []byte) ([]byte, error)
	Delete(key []byte) error
	ForEach(br state.ByteSpan, fn func(key, value []byte) error) error
}

Jump to

Keyboard shortcuts

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