basedb

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database added in v1.1.0

type Database interface {
	ReadWriter

	Begin() Txn
	BeginRead() ReadTxn

	Using(rw ReadWriter) ReadWriter
	UsingReader(r Reader) Reader

	// TODO: consider moving these functions into Reader and ReadWriter interfaces?
	CountPrefix(prefix []byte) (int64, error)
	DeletePrefix(prefix []byte) (int, error)
	DropPrefix(prefix []byte) error
	Update(fn func(Txn) error) error
	Close() error
}

Database interface for Badger DB

type GarbageCollector added in v0.4.7

type GarbageCollector interface {
	// QuickGC runs a short garbage collection cycle to reclaim some unused disk space.
	// Designed to be called periodically while the database is being used.
	QuickGC(context.Context) error

	// FullGC runs a long garbage collection cycle to reclaim (ideally) all unused disk space.
	// Designed to be called when the database is not being used.
	FullGC(context.Context) error
}

GarbageCollector is an interface implemented by storage engines which demand garbage collection.

type Obj

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

Obj struct for getting key/value from storage

type Options

type Options struct {
	Ctx        context.Context
	Path       string        `yaml:"Path" env:"DB_PATH" env-default:"./data/db" env-description:"Path for storage"`
	Reporting  bool          `yaml:"Reporting" env:"DB_REPORTING" env-default:"false" env-description:"Flag to run on-off db size reporting"`
	GCInterval time.Duration `` /* 138-byte string literal not displayed */
}

Options for creating all db type

type ReadTxn added in v1.1.0

type ReadTxn interface {
	Reader
	Discard()
}

type ReadWriter added in v1.1.0

type ReadWriter interface {
	Reader
	Set(prefix []byte, key []byte, value []byte) error
	SetMany(prefix []byte, n int, next func(int) (Obj, error)) error
	Delete(prefix []byte, key []byte) error
}

ReadWrite is a read-write accessor to the database.

type Reader added in v1.1.0

type Reader interface {
	Get(prefix []byte, key []byte) (Obj, bool, error)
	GetMany(prefix []byte, keys [][]byte, iterator func(Obj) error) error
	GetAll(prefix []byte, handler func(int, Obj) error) error
}

Reader is a read-only accessor to the database.

type Txn added in v0.1.11

type Txn interface {
	ReadWriter
	// TODO: add iterator
	Commit() error
	Discard()
}

Txn is a read-write transaction.

Jump to

Keyboard shortcuts

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