storage

package
v0.0.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoResults is returned when no results have been found (e.g., in a seek)
	ErrNoResults = errors.New("could not find any results")
)

Functions

func BytesToUint64

func BytesToUint64(b []byte) uint64

func NewDiskStorage

func NewDiskStorage(dataPath string) *diskStorage

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Types

type KeyValue

type KeyValue struct {
	Key   []byte
	Value []byte
}

type Storage

type Storage interface {
	Set(key []byte, value []byte) error
	Get(key []byte) ([]byte, error)
	Increment(key []byte) (uint64, error)
	SetBatch(batch []KeyValue) error
	Contains(key []byte) bool
	GetFirst(count int) ([][]byte, error)
	GetRange(from []byte, to []byte) ([][]byte, error)
	TotalCount() (uint64, error)
	CountRange(from []byte, to []byte) (uint64, error)
	Iterate(prefix []byte, f func([]byte, func() ([]byte, error)) (bool, error)) error
	IterateReverse(prefix []byte, f func([]byte, func() ([]byte, error)) (bool, error)) error
	Seek(key []byte) (KeyValue, error)
	CountPrefix(prefix []byte) (uint64, error)
	Close()
}

type StorageGenerator

type StorageGenerator func(string) Storage

func NewDiskStorageGenerator

func NewDiskStorageGenerator() StorageGenerator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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