database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 9 Imported by: 141

Documentation

Overview

Package database provides KV database for meta-information

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("key not found")
)

Errors for Storage

Functions

func RecoverDB added in v0.5.1

func RecoverDB(path string) error

RecoverDB recovers LevelDB database from corruption

Types

type Storage

type Storage interface {
	CreateTemporary() (Storage, error)
	Get(key []byte) ([]byte, error)
	Put(key []byte, value []byte) error
	Delete(key []byte) error
	HasPrefix(prefix []byte) bool
	ProcessByPrefix(prefix []byte, proc StorageProcessor) error
	KeysByPrefix(prefix []byte) [][]byte
	FetchByPrefix(prefix []byte) [][]byte
	Open() error
	Close() error
	StartBatch()
	FinishBatch() error
	CompactDB() error
	Drop() error
}

Storage is an interface to KV storage

func NewDB added in v1.1.0

func NewDB(path string) (Storage, error)

NewDB creates new instance of DB, but doesn't open it (yet)

func NewOpenDB added in v1.1.0

func NewOpenDB(path string) (Storage, error)

NewOpenDB creates new instance of DB and opens it

type StorageProcessor added in v1.0.0

type StorageProcessor func(key []byte, value []byte) error

StorageProcessor is a function to process one single storage entry

Jump to

Keyboard shortcuts

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