badger

package
v0.0.0-...-bcfd2cf Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Badger

type Badger struct {
	*badger.DB
}

Badger client wrapper

func NewBadger

func NewBadger(conf *Config, readonly bool) (*Badger, error)

NewBadger creates a new instance of the db

func (*Badger) Delete

func (b *Badger) Delete(key string) (err error)

Delete inserts in the db the block as []byte passed

func (*Badger) Empty

func (b *Badger) Empty() (err error)

Empty empties the badger store

func (*Badger) IsStored

func (b *Badger) IsStored(key string) bool

IsStored returns true if the block corresponding to passed hash is stored in db

func (*Badger) Read

func (b *Badger) Read(key string) (value []byte, err error)

Read extract required value by key

func (*Badger) ReadFirstValueByPrefix

func (b *Badger) ReadFirstValueByPrefix(prefix string) (value []byte, err error)

ReadFirstValueByPrefix returns the first value matched by prefix

func (*Badger) ReadKeyValues

func (b *Badger) ReadKeyValues() (value map[string][]byte, err error)

ReadKeyValues concurrent read values based on a prefix

func (*Badger) ReadKeys

func (b *Badger) ReadKeys() (value []string, err error)

ReadKeys concurrent read values based on a prefix

func (*Badger) ReadKeysWithPrefix

func (b *Badger) ReadKeysWithPrefix(prefix string) (keys []string, err error)

ReadKeysWithPrefix concurrent read values based on a prefix

func (*Badger) ReadPrefix

func (b *Badger) ReadPrefix(prefix string) (value [][]byte, err error)

ReadPrefix concurrent read values based on a prefix

func (*Badger) ReadPrefixWithKey

func (b *Badger) ReadPrefixWithKey(prefix string) (value map[string][]byte, err error)

ReadPrefixWithKey concurrent read values based on a prefix

func (*Badger) Store

func (b *Badger) Store(key string, value []byte) error

Store insert new key-value in badger

func (*Badger) StoreBatch

func (b *Badger) StoreBatch(batch interface{}) (err error)

StoreBatch insert new key-value in badger

func (*Badger) StoreQueueBatch

func (b *Badger) StoreQueueBatch(v interface{}) (err error)

StoreQueueBatch loads a queue until a threshold to perform a bulk insertion

type Config

type Config struct {
	Dir string
}

Config strcut containing initialization fields

func Conf

func Conf(path string) *Config

Conf returnes default config struct

type KV

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

KV instance of key value store designed to treat block structs

func NewKV

func NewKV(bdg *Badger, c *cache.Cache) (*KV, error)

NewKV creates a new instance of KV

Jump to

Keyboard shortcuts

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