Help us shape the future of Go! Take the 2026 Go Developer Survey

database

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 1 Imported by: 46

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

This section is empty.

Types

type Batch added in v1.5.0

type Batch interface {
	Writer

	// Write closes batch and send accumulated writes to the database
	Write() error
}

Batch provides a way to pack many writes.

type PrefixReader added in v1.5.0

type PrefixReader interface {
	HasPrefix(prefix []byte) bool
	ProcessByPrefix(prefix []byte, proc StorageProcessor) error
	KeysByPrefix(prefix []byte) [][]byte
	FetchByPrefix(prefix []byte) [][]byte
}

PrefixReader provides prefixed operations

type Reader added in v1.5.0

type Reader interface {
	Get(key []byte) ([]byte, error)
}

Reader provides KV read calls

type ReaderWriter added in v1.5.0

type ReaderWriter interface {
	Reader
	Writer
}

ReaderWriter combines Reader and Writer

type Storage

type Storage interface {
	Reader
	Writer

	PrefixReader

	CreateBatch() Batch
	OpenTransaction() (Transaction, error)

	CreateTemporary() (Storage, error)

	Open() error
	Close() error
	CompactDB() error
	Drop() error
}

Storage is an interface to KV storage

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

type Transaction added in v1.5.0

type Transaction interface {
	Reader
	Writer

	Commit() error
	Discard()
}

Transaction provides isolated atomic way to perform updates.

Transactions might be expensive. Transaction should always finish with either Discard() or Commit()

type Writer added in v1.5.0

type Writer interface {
	Put(key []byte, value []byte) error
	Delete(key []byte) error
}

Writer provides KV update/delete calls

Directories

Path Synopsis
Package goleveldb implements database interface via goleveldb
Package goleveldb implements database interface via goleveldb

Jump to

Keyboard shortcuts

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