badgerdb

package
v0.0.0-...-bb1a4e7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(plainPwd, hash string) bool

func Hash

func Hash(data string) string

func Serialize

func Serialize(item interface{}) []byte

func Unserialize

func Unserialize(data []byte, item interface{}) error

Types

type BadgerStorage

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

func NewBadgerStorageGC

func NewBadgerStorageGC(options *Options) (*BadgerStorage, error)

New uses the supplied options to open the Badger badgerdb and prepare it for use as a raft backend.

func NewCollection

func NewCollection(databaseRootPath, name string) (*BadgerStorage, error)

func (*BadgerStorage) Add

func (storage *BadgerStorage) Add(key, data []byte) error

func (*BadgerStorage) Close

func (storage *BadgerStorage) Close() error

Close is used to gracefully close the DB connection.

func (*BadgerStorage) Delete

func (storage *BadgerStorage) Delete(key []byte) error

func (*BadgerStorage) DeleteRange

func (storage *BadgerStorage) DeleteRange(min, max uint64) error

DeleteRange deletes logs within a given range inclusively.

func (*BadgerStorage) Get

func (storage *BadgerStorage) Get(key []byte) ([]byte, error)

Get is used to retrieve a value from the k/v store by key

func (*BadgerStorage) GetUint64

func (storage *BadgerStorage) GetUint64(key []byte) (uint64, error)

GetUint64 is like Get, but handles uint64 values

func (*BadgerStorage) List

func (storage *BadgerStorage) List(prefixStr string, decoderModel db.DaoInterface) ([]db.DaoInterface, error)

func (*BadgerStorage) PutUniqueKeyValue

func (storage *BadgerStorage) PutUniqueKeyValue(key []byte, value []byte) error

func (*BadgerStorage) SetCompositeKey

func (storage *BadgerStorage) SetCompositeKey(key []byte, val []byte) error

func (*BadgerStorage) SetRawKey

func (storage *BadgerStorage) SetRawKey(key []byte, val []byte) error

func (*BadgerStorage) SetUint64

func (storage *BadgerStorage) SetUint64(key []byte, val uint64) error

SetUint64 is like Set, but handles uint64 values

type Options

type Options struct {
	// Path is the directory path to the Badger badgerdb to use.
	Path string

	// BadgerOptions contains any specific Badger options you might
	// want to specify.
	BadgerOptions *badger.Options

	// NoSync causes the database to skip fsync calls after each
	// write to the log. This is unsafe, so it should be used
	// with caution.
	NoSync bool

	// ValueLogGC enables a periodic goroutine that does a garbage
	// collection of the value log while the underlying Badger is online.
	ValueLogGC bool

	// GCInterval is the interval between conditionally running the garbage
	// collection process, based on the size of the vlog. By default, runs every 1m.
	GCInterval fastime.Duration

	// GCInterval is the interval between mandatory running the garbage
	// collection process. By default, runs every 10m.
	MandatoryGCInterval fastime.Duration

	// GCThreshold sets threshold in bytes for the vlog size to be included in the
	// garbage collection cycle. By default, 1GB.
	GCThreshold int64
}

Options contains all the configuration used to open the Badger badgerdb

Jump to

Keyboard shortcuts

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