gdb

package
v0.0.0-...-04777cf Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection interface {
	Get(key []byte) (value []byte, err error)
	Set(key, value []byte) error
	Has(key []byte) (bool, error)
}

Collection defines an embedded key/value store database interface. we could think of the Collection as a SQL table name or a mongodb collection name

type DB

type DB interface {
	CreateNsCollection(ns string) Collection
	Close() error
}

func NewBadgerDB

func NewBadgerDB(kvOpts ...KvDBOption) (DB, error)

NewBadgerDB returns a new initialized badgerDB database implementing the DB interface. If the database cannot be initialized, an error will be returned.

type KvDBOption

type KvDBOption func(*rootConfig) error

func WithDataDir

func WithDataDir(dir string) KvDBOption

WithDataDir sets the data directory for the badgerDB database.

func WithGcDiscardRatio

func WithGcDiscardRatio(ratio float64) KvDBOption

WithGcDiscardRatio sets the garbage collection discard ratio for the badgerDB database.

func WithGcInterval

func WithGcInterval(interval time.Duration) KvDBOption

WithGcInterval sets the garbage collection interval for the badgerDB database.

func WithLogger

func WithLogger(logger zerolog.Logger) KvDBOption

WithLogger sets the logger for the badgerDB database.

Jump to

Keyboard shortcuts

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