database

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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, lightMode bool)

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

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

func Get

func Get(name string) (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