kv

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0, BSD-2-Clause Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const EmptyPrefix = Key("")

Variables

This section is empty.

Functions

func ByteSize added in v0.2.0

func ByteSize(s KVStoreReader) int

func MustGet added in v0.1.0

func MustGet(kvs KVStoreReader, key Key) []byte

func MustHas added in v0.1.0

func MustHas(kvs KVStoreReader, key Key) bool

func MustIterate added in v0.1.0

func MustIterate(kvs KVStoreReader, prefix Key, f func(key Key, value []byte) bool)

func MustIterateKeys added in v0.1.0

func MustIterateKeys(kvs KVStoreReader, prefix Key, f func(key Key) bool)

func MustIterateKeysSorted added in v0.2.0

func MustIterateKeysSorted(kvs KVStoreReader, prefix Key, f func(key Key) bool)

func MustIterateSorted added in v0.2.0

func MustIterateSorted(kvs KVStoreReader, prefix Key, f func(key Key, value []byte) bool)

Types

type DBError

type DBError struct {
	// contains filtered or unexported fields
}

func (*DBError) Error

func (d *DBError) Error() string

func (*DBError) Unwrap added in v0.2.0

func (d *DBError) Unwrap() error

type HiveKVStoreReader added in v0.2.0

type HiveKVStoreReader struct {
	// contains filtered or unexported fields
}

HiveKVStoreReader is an implementation of KVStoreReader with an instance of hive's kvstore.KVStore as backend.

func NewHiveKVStoreReader added in v0.2.0

func NewHiveKVStoreReader(db kvstore.KVStore) *HiveKVStoreReader

func (*HiveKVStoreReader) Get added in v0.2.0

func (h *HiveKVStoreReader) Get(key Key) ([]byte, error)

Get returns the value, or nil if not found

func (*HiveKVStoreReader) Has added in v0.2.0

func (h *HiveKVStoreReader) Has(key Key) (bool, error)

func (*HiveKVStoreReader) Iterate added in v0.2.0

func (h *HiveKVStoreReader) Iterate(prefix Key, f func(key Key, value []byte) bool) error

func (*HiveKVStoreReader) IterateKeys added in v0.2.0

func (h *HiveKVStoreReader) IterateKeys(prefix Key, f func(key Key) bool) error

func (*HiveKVStoreReader) IterateKeysSorted added in v0.2.0

func (h *HiveKVStoreReader) IterateKeysSorted(prefix Key, f func(key Key) bool) error

func (*HiveKVStoreReader) IterateSorted added in v0.2.0

func (h *HiveKVStoreReader) IterateSorted(prefix Key, f func(key Key, value []byte) bool) error

func (*HiveKVStoreReader) MustGet added in v0.2.0

func (h *HiveKVStoreReader) MustGet(key Key) []byte

MustGet returns the value, or nil if not found

func (*HiveKVStoreReader) MustHas added in v0.2.0

func (h *HiveKVStoreReader) MustHas(key Key) bool

func (*HiveKVStoreReader) MustIterate added in v0.2.0

func (h *HiveKVStoreReader) MustIterate(prefix Key, f func(key Key, value []byte) bool)

func (*HiveKVStoreReader) MustIterateKeys added in v0.2.0

func (h *HiveKVStoreReader) MustIterateKeys(prefix Key, f func(key Key) bool)

func (*HiveKVStoreReader) MustIterateKeysSorted added in v0.2.0

func (h *HiveKVStoreReader) MustIterateKeysSorted(prefix Key, f func(key Key) bool)

func (*HiveKVStoreReader) MustIterateSorted added in v0.2.0

func (h *HiveKVStoreReader) MustIterateSorted(prefix Key, f func(key Key, value []byte) bool)

type Item added in v0.2.0

type Item struct {
	Key   Key
	Value []byte
}

type Items added in v0.2.0

type Items []Item

func (Items) Len added in v0.2.0

func (items Items) Len() int

func (Items) Less added in v0.2.0

func (items Items) Less(i, j int) bool

func (Items) Swap added in v0.2.0

func (items Items) Swap(i, j int)

type KVIterator added in v0.2.0

type KVIterator interface {
	Iterate(prefix Key, f func(key Key, value []byte) bool) error
	IterateKeys(prefix Key, f func(key Key) bool) error

	IterateSorted(prefix Key, f func(key Key, value []byte) bool) error
	IterateKeysSorted(prefix Key, f func(key Key) bool) error
}

type KVMustIterator added in v0.2.0

type KVMustIterator interface {
	MustIterate(prefix Key, f func(key Key, value []byte) bool)
	MustIterateKeys(prefix Key, f func(key Key) bool)

	MustIterateSorted(prefix Key, f func(key Key, value []byte) bool)
	MustIterateKeysSorted(prefix Key, f func(key Key) bool)
}

type KVMustReader added in v0.2.0

type KVMustReader interface {
	// MustGet returns the value, or nil if not found
	MustGet(key Key) []byte
	MustHas(key Key) bool
}

type KVReader added in v0.2.0

type KVReader interface {
	// Get returns the value, or nil if not found
	Get(key Key) ([]byte, error)
	Has(key Key) (bool, error)
}

type KVStore

type KVStore interface {
	KVWriter
	KVStoreReader
}

KVStore represents a key-value store where both keys and values are arbitrary byte slices.

type KVStoreReader added in v0.1.0

type KVStoreReader interface {
	KVReader
	KVIterator
	KVMustReader
	KVMustIterator
}

type KVWriter added in v0.2.0

type KVWriter interface {
	Set(key Key, value []byte)
	Del(key Key)
}

type Key

type Key string

Since map cannot have []byte as key, to avoid unnecessary conversions between string and []byte, we use string as key data type, but it does not necessarily have to be a valid UTF-8 string.

func (Key) HasPrefix

func (k Key) HasPrefix(prefix Key) bool

func (Key) Hex added in v0.2.0

func (k Key) Hex() string

Directories

Path Synopsis
optimism package implements primitives needed for te optimistic read of the chain's state
optimism package implements primitives needed for te optimistic read of the chain's state

Jump to

Keyboard shortcuts

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