db

package
v0.0.46 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRaft added in v0.0.30

func GetRaft(ctx context.Context) *badger.DB

func Observe added in v0.0.42

func Observe(ctx context.Context, prefix []byte, obs func(context.Context, *badger.KVList))

Observe watches for database changes on key prefix and call obs withe changed keys.

func Open added in v0.0.19

func Open(ctx context.Context, path string, logLevel ...string) (context.Context, *badger.DB)

func OpenRaft added in v0.0.30

func OpenRaft(ctx context.Context, path string) (context.Context, *badger.DB)

func Path added in v0.0.44

func Path(dbPath string) string

Path returns full path where badger db is created. We also store socket file to mysql inside dbPath directory to avoid having non badger managed files in its directory we create a subdirectory for badger.

func Set

Types

type Iter added in v0.0.30

type Iter interface {
	Rewind()
	Valid() bool
	Next()
	Key() []byte
	Value(value func([]byte) error) error
	Close()
}

type IterOpts added in v0.0.30

type IterOpts struct {
	Prefix         []byte
	PrefetchValues bool
	PrefetchSize   int
	Reverse        bool
}

type Provider added in v0.0.30

type Provider interface {
	With(func(db *badger.DB) error) error
	NewTransaction(update bool) Txn
	Txn(update bool, f func(txn Txn) error) error
}

func Get

func Get(ctx context.Context) Provider

type Txn added in v0.0.30

type Txn interface {
	Set(key, value []byte) error
	SetTTL(key, value []byte, ttl time.Duration) error

	// Get retrieves a key and calls value with the data. When the key is not found
	// and nofFound is present then notFound is called.
	Get(key []byte, value func(val []byte) error, notFound ...func() error) error
	Has(key []byte) bool
	Delete(key []byte, notFound ...func() error) error
	Close() error

	Iter(IterOpts) Iter
}

Jump to

Keyboard shortcuts

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