kvstore

package
v1.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0, BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyType

type KeyType interface {
	Bytes() ([]byte, error)
}

KeyType is a type constraints for the keys of the TypedStore.

type TypedStore

type TypedStore[K KeyType, V any, VPtr ValuePtrType[V]] struct {
	// contains filtered or unexported fields
}

TypedStore is a generically typed wrapper around a KVStore that abstracts serialization away.

func NewTypedStore

func NewTypedStore[K KeyType, V any, VPtr ValuePtrType[V]](kv kvstore.KVStore) *TypedStore[K, V, VPtr]

NewTypedStore is the constructor for TypedStore.

func (*TypedStore[K, V, VPtr]) Get

func (t *TypedStore[K, V, VPtr]) Get(key K) (value VPtr, err error)

Get gets the given key or an error if an error occurred.

func (*TypedStore[K, V, VPtr]) Set

func (t *TypedStore[K, V, VPtr]) Set(key K, value VPtr) (err error)

Set sets the given key and value.

type ValuePtrType

type ValuePtrType[V any] interface {
	*V

	FromBytes([]byte) (consumedBytes int, err error)
	Bytes() ([]byte, error)
}

ValuePtrType is a type constraints for values of the TypedStore.

Jump to

Keyboard shortcuts

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