buffered

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0, BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMutationDel

func NewMutationDel(k kv.Key) *mutationDel

func NewMutationSet

func NewMutationSet(k kv.Key, v []byte) *mutationSet

Types

type BufferedKVStore

type BufferedKVStore interface {
	kv.KVStore

	// the uncommitted mutations
	Mutations() MutationSequence
	ClearMutations()
	Clone() BufferedKVStore

	// only for testing!
	DangerouslyDumpToDict() dict.Dict
	// only for testing!
	DangerouslyDumpToString() string
}

BufferedKVStore represents a KVStore backed by a database. Writes are cached in-memory as a MutationSequence; reads are delegated to the backing database when not cached.

func NewBufferedKVStore

func NewBufferedKVStore(db kvstore.KVStore) BufferedKVStore

type DBError

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

Any failed access to the DB will return an instance of DBError

func (DBError) Error

func (d DBError) Error() string

type Mutation

type Mutation interface {
	Read(io.Reader) error
	Write(io.Writer) error

	String() string

	ApplyTo(w kv.KVStoreWriter)

	// Key returns the key that is mutated
	Key() kv.Key
	// Value returns the value after the mutation (nil if deleted)
	Value() []byte
	// contains filtered or unexported methods
}

Mutation represents a single "set" or "del" operation over a KVStore

type MutationSequence

type MutationSequence interface {
	Read(io.Reader) error
	Write(io.Writer) error

	String() string

	Clone() MutationSequence

	Len() int

	// Iterate over all mutations in order, even ones affecting the same key repeatedly
	Iterate(func(mut Mutation) bool)
	// Iterate over the latest mutation recorded for each key
	IterateLatest(func(key kv.Key, mut Mutation) bool)
	// Iterate over the latest value recorded for each non-deleted key
	IterateValues(prefix kv.Key, f func(key kv.Key, value []byte) bool) (map[kv.Key]bool, bool)

	Latest(key kv.Key) Mutation

	Add(mut Mutation)

	ApplyTo(w kv.KVStoreWriter)
}

func NewMutationSequence

func NewMutationSequence() MutationSequence

Jump to

Keyboard shortcuts

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