badgerdb

package
v0.0.0-...-32dd017 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func New

func New(l logger.Logger, path string) (*DB, error)

func (*DB) Delete

func (d *DB) Delete(ctx context.Context, key []byte) error

Delete removes a key from BadgerDB

func (*DB) Exists

func (d *DB) Exists(ctx context.Context, key []byte) (bool, error)

Exists checks if a key exists in BadgerDB

func (*DB) Get

func (d *DB) Get(ctx context.Context, key []byte) ([]byte, error)

Get retrieves a value by key from BadgerDB

func (*DB) GetFromJSON

func (d *DB) GetFromJSON(ctx context.Context, key []byte, dst any) error

GetFromJSON retrieves a value and unmarshals it into dst

func (*DB) Keys

func (d *DB) Keys(ctx context.Context, prefix []byte) ([]string, error)

Keys returns all keys with the given prefix

func (*DB) KeysAndValues

func (d *DB) KeysAndValues(ctx context.Context, prefix []byte) (map[string][]byte, error)

KeysAndValues returns all keys and values with the given prefix

func (*DB) Name

func (d *DB) Name() string

Named returns the name of the database engine.

func (*DB) Set

func (d *DB) Set(ctx context.Context, key []byte, value []byte, expiration time.Duration) error

Set stores a key-value pair with optional expiration

func (*DB) SetJSON

func (d *DB) SetJSON(ctx context.Context, key []byte, value any, expiration time.Duration) error

SetJSON marshals value to JSON and stores it

func (*DB) Start

func (d *DB) Start(_ context.Context) error

Start starts the database engine.

func (*DB) Stop

func (d *DB) Stop(_ context.Context) error

Stop stops the database engine.

Jump to

Keyboard shortcuts

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