basedb

package
v0.5.5-jatov2-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: GPL-3.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 IDb

type IDb interface {
	Set(prefix []byte, key []byte, value []byte) error
	SetMany(prefix []byte, n int, next func(int) (Obj, error)) error
	Get(prefix []byte, key []byte) (Obj, bool, error)
	GetMany(logger *zap.Logger, prefix []byte, keys [][]byte, iterator func(Obj) error) error
	Delete(prefix []byte, key []byte) error
	DeleteByPrefix(prefix []byte) (int, error)
	GetAll(logger *zap.Logger, prefix []byte, handler func(int, Obj) error) error
	CountByCollection(prefix []byte) (int64, error)
	RemoveAllByCollection(prefix []byte) error
	Update(fn func(Txn) error) error
	Close(logger *zap.Logger) error
}

IDb interface for all db kind

type Obj

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

Obj struct for getting key/value from storage

type Options

type Options struct {
	Type       string        `yaml:"Type" env:"DB_TYPE" env-default:"badger-db" env-description:"Type of db badger-db or badger-memory"`
	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 */
	Ctx        context.Context
}

Options for creating all db type

type Txn added in v0.1.11

type Txn interface {
	Set(prefix []byte, key []byte, value []byte) error
	Get(prefix []byte, key []byte) (Obj, bool, error)
	Delete(prefix []byte, key []byte) error
}

Txn interface for badger transaction like functions

Jump to

Keyboard shortcuts

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