db

package
v0.0.0-...-8b27293 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue(db *badger.DB, key string) (error, []byte)

func List

func List(db *badger.DB, prefix string) error

func OpenBadgerDB

func OpenBadgerDB(dir string, logLevel int) (*badger.DB, error)

func Set

func Set(db *badger.DB, key string, value string) (err error)

func UpdateBadgerDB

func UpdateBadgerDB(db *badger.DB, updates map[string]string) (err error)

Types

type BadgerDB

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

BadgerDB is a wrapper around a BadgerDB backend database that implements the DB interface.

func NewBadgerDB

func NewBadgerDB(dataDir string, logger *badger.Logger) (*BadgerDB, error)

func (*BadgerDB) Close

func (bdb *BadgerDB) Close() error

Close implements the DB interface. It closes the connection to the underlying BadgerDB database as well as invoking the context's cancel function.

func (*BadgerDB) Delete

func (bdb *BadgerDB) Delete(namespace, key []byte) error

func (*BadgerDB) Get

func (bdb *BadgerDB) Get(namespace, key []byte) (value []byte, err error)

func (*BadgerDB) Has

func (bdb *BadgerDB) Has(namespace, key []byte) (ok bool, err error)

func (*BadgerDB) List

func (bdb *BadgerDB) List(namespace, prefix []byte) error

Prefix scans

func (*BadgerDB) Set

func (bdb *BadgerDB) Set(namespace, key, value []byte) error

func (*BadgerDB) SetWithMeta

func (bdb *BadgerDB) SetWithMeta(namespace, key, value []byte, meta byte) error

func (*BadgerDB) SetWithTTL

func (bdb *BadgerDB) SetWithTTL(namespace, key, value []byte, ttl time.Duration) error

type DB

type DB interface {
	Get(namespace, key []byte) (value []byte, err error)
	Set(namespace, key, value []byte) error
	SetWithTTL(namespace, key, value []byte, ttl time.Duration) error
	SetWithMeta(namespace, key, value []byte, meta byte) error
	Delete(namespace, key []byte) error
	Has(namespace, key []byte) (bool, error)
	List(namespace, prefix []byte) error
	Close() error
}

DB defines an embedded key/value store database interface.

Jump to

Keyboard shortcuts

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