badgerutils

package module
v0.0.0-...-50414e9 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 6 Imported by: 0

README

badgerutils

A set of utility infrastructures which makes working with badger-db easier as an embedded database

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithRegistryKeyLen

func WithRegistryKeyLen(keyLen int) func(*NameRegistry)

WithRegistryKeyLen sets the key length for the NameRegistry.

func WithRegistryPrefix

func WithRegistryPrefix(prefix []byte) func(*NameRegistry)

WithRegistryPrefix sets the prefix for the NameRegistry.

Types

type BadgerIterator

type BadgerIterator interface {
	Close()
	Item() *badger.Item
	Next()
	Rewind()
	Seek(key []byte)
	Valid() bool
}

BadgerIterator is the interface that represents a badger iterator.

type BadgerStore

type BadgerStore interface {
	StoreInstance[[]byte, *badger.Item, []byte, *badger.Iterator]
	SetEntry(e *badger.Entry) error
}

BadgerStore is an store instance that is compatible with *badger.Txn

type Instantiator

type Instantiator[I any] interface {
	Instantiate(txn *badger.Txn) I
}

Instantiator is an interface that creates a new instance of something from a badger transaction.

type Iterator

type Iterator[K, V any] interface {
	ValueIterator[V]
	Key() (K, error)
}

Iterator is an interface that extends ValueIterator with a Key method.

type NameRegistry

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

NameRegistry associates a long string name with a unique sized byte slice.

func NewNameRegistry

func NewNameRegistry(db *badger.DB, opts ...func(*NameRegistry)) (*NameRegistry, error)

NewNameRegistry creates a new NameRegistry.

func (*NameRegistry) MustName

func (nreg *NameRegistry) MustName(name string) []byte

MustName is like Name but panics if an error occurs.

func (*NameRegistry) Name

func (nreg *NameRegistry) Name(name string) ([]byte, error)

Name associates a name with a unique key.

type RawKVPair

type RawKVPair struct {
	Key   []byte
	Value []byte
}

RawKVPair is a key-value pair with both key and value as byte slices.

func NewRawKVPair

func NewRawKVPair(key, value []byte) RawKVPair

NewRawKVPair creates a new RawKVPair.

type StoreInstance

type StoreInstance[K, G, S any, I BadgerIterator] interface {
	Delete(key K) error
	Get(key K) (v G, err error)
	NewIterator(opts badger.IteratorOptions) I
	Set(key K, value S) error
}

StoreInstance is a store that works with serialized values.

type ValueIterator

type ValueIterator[V any] interface {
	BadgerIterator
	Value() (V, error)
}

ValueIterator is an interface that extends BadgerIterator with a Value method.

Directories

Path Synopsis
be
lex
internal
store
ext
rec
ref

Jump to

Keyboard shortcuts

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