database

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamNumGoRoutines = 16
)

Variables

View Source
var (
	ErrKeyNotFound = badger.ErrKeyNotFound
)

Functions

func CleanupBadgerInstance

func CleanupBadgerInstance()

func CloseDatabase

func CloseDatabase() error

func GetBadgerInstance

func GetBadgerInstance() *badger.DB

func Settings

func Settings(dir string)

Settings sets DB dir and light mode

Types

type Database

type Database interface {
	// Read
	Contains(key Key) (bool, error)
	Get(key Key) (Entry, error)
	GetKeyOnly(key Key) (KeyOnlyEntry, error)

	// Write
	Set(entry Entry) error
	Delete(key Key) error
	DeletePrefix(keyPrefix KeyPrefix) error

	// Iteration
	ForEach(func(entry Entry) (stop bool)) error
	ForEachPrefix(keyPrefix KeyPrefix, do func(entry Entry) (stop bool)) error
	ForEachPrefixKeyOnly(keyPrefix KeyPrefix, do func(entry KeyOnlyEntry) (stop bool)) error
	StreamForEach(func(entry Entry) error) error
	StreamForEachKeyOnly(func(entry KeyOnlyEntry) error) error
	StreamForEachPrefix(keyPrefix KeyPrefix, do func(entry Entry) error) error
	StreamForEachPrefixKeyOnly(keyPrefix KeyPrefix, do func(entry KeyOnlyEntry) error) error

	// Transactions
	Apply(set []Entry, delete []Key) error
}

func Get

func Get(dbPrefix byte) (Database, error)

type Entry

type Entry struct {
	Key   Key
	Value Value
	Meta  byte
}

type Key

type Key []byte

type KeyOnlyEntry

type KeyOnlyEntry struct {
	Key  Key
	Meta byte
}

type KeyPrefix

type KeyPrefix []byte

type Value

type Value []byte

Jump to

Keyboard shortcuts

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