badgerdb

package
v0.0.2-beta.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Path string `json:"path"`
}

Config holds configuration options for BadgerDB.

type Database

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

Database is a BadgerDB-backed cache implementation that provides persistent key-value storage. It implements the ByteCache interface using BadgerDB as the underlying storage engine.

func NewDatabase

func NewDatabase(config *Config) (*Database, error)

NewDatabase creates a new BadgerDB cache with the specified configuration. It opens a BadgerDB instance at the configured path with default options.

func NewDatabaseWithBadger

func NewDatabaseWithBadger(db *badger.DB) *Database

NewDatabaseWithBadger creates a new Database wrapper around an existing BadgerDB instance. This allows for advanced configuration and sharing of BadgerDB instances.

func NewDatabaseWithOptions

func NewDatabaseWithOptions(opts badger.Options) (*Database, error)

NewDatabaseWithOptions creates a new BadgerDB cache with custom BadgerDB options. This provides full control over BadgerDB configuration such as compression, encryption, etc.

func (*Database) Close

func (d *Database) Close() error

func (*Database) Del

func (d *Database) Del(ctx context.Context, key string) error

func (*Database) DelAll

func (d *Database) DelAll(ctx context.Context) error

func (*Database) Exists

func (d *Database) Exists(ctx context.Context, key string) (bool, error)

func (*Database) Get

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

func (*Database) MultiDel

func (d *Database) MultiDel(ctx context.Context, keys []string) error

func (*Database) MultiGet

func (d *Database) MultiGet(ctx context.Context, keys []string) (map[string][]byte, error)

func (*Database) MultiSet

func (d *Database) MultiSet(ctx context.Context, valMap map[string][]byte) error

func (*Database) MultiSetWithTTL

func (d *Database) MultiSetWithTTL(ctx context.Context, valMap map[string][]byte, expiration time.Duration) error

func (*Database) Set

func (d *Database) Set(ctx context.Context, key string, val []byte) error

func (*Database) SetWithTTL

func (d *Database) SetWithTTL(ctx context.Context, key string, val []byte, expiration time.Duration) error

func (*Database) Sync

func (d *Database) Sync() error

Jump to

Keyboard shortcuts

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