badger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter adapter ensures that the badger key/values store implmentes our interface

func NewAdapter

func NewAdapter(db *badger.DB) *Adapter

NewAdapter returns a new Adapter for key/value logic

func (*Adapter) Close

func (b *Adapter) Close()

Close ensures the db is flushed to disk and put into a good state

func (*Adapter) Delete

func (b *Adapter) Delete(key []byte) (int, error)

Delete the record at the []byte value. Returns 1,nil on success or 0, error on failure A call to get directly afterwards should return nil

func (*Adapter) DeletePrefix

func (b *Adapter) DeletePrefix(prefix []byte) (int, error)

DeletePrefix should delete all records for which bytes.HasPrefix(key, prefix) is true; Returns the number of records deleted.

func (*Adapter) Get

func (b *Adapter) Get(key []byte) []byte

Get returns the []byte value of a specific key; or nil otherwise

func (*Adapter) PrefixScan

func (b *Adapter) PrefixScan(
	prefix []byte,
	mapper func(key []byte, value []byte) error,
) error

PrefixScan iterates all over all []byte keys where bytes.HasPrefix(key, prefix) == true; and calls the callback with the keys and values.

func (*Adapter) Put

func (b *Adapter) Put(key []byte, value []byte, ttl *time.Duration) error

Put store a []byte value at a given []byte key

Jump to

Keyboard shortcuts

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