database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StreamNumGoRoutines = 16
)

Variables

View Source
var (
	ErrKeyNotFound = badger.ErrKeyNotFound
)

Functions

func CreateDB

func CreateDB(directory string, optionalOptions ...badger.Options) (*badger.DB, error)

func GetBadgerInstance

func GetBadgerInstance(optionalDirectory ...string) *badger.DB

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, optionalBadger ...*badger.DB) (Database, error)

type Entry

type Entry struct {
	Key   Key
	Value Value
	Meta  byte
	TTL   time.Duration
}

type Key

type Key []byte

type KeyOnlyEntry

type KeyOnlyEntry struct {
	Key  Key
	Meta byte
}

type KeyPrefix

type KeyPrefix []byte

type Value

type Value []byte

Directories

Path Synopsis
Package mapdb provides a map implementation of a key value database.
Package mapdb provides a map implementation of a key value database.

Jump to

Keyboard shortcuts

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