kv

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KV

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

KV provides key-value storage

func New

func New(dbPath string) (KV, error)

New creates a new KV store. This should be invoked by AK itself, not modules

func (KV) Close

func (kv KV) Close() error

Close the KV

func (KV) WithPrefix

func (kv KV) WithPrefix(prefix [prefixLen]byte) *KVPrefix

WithPrefix creates a wrapped KV where all keys are forced to have a given prefix. This segregates values from each module

type KVPrefix

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

func (KVPrefix) Delete

func (p KVPrefix) Delete(k []byte) error

Delete a value from the store, if the key is present

func (KVPrefix) Get

func (p KVPrefix) Get(k []byte) ([]byte, error)

Get a value. If no value is found with this key, akcore.ErrNotFound is returned.

func (KVPrefix) GetProto

func (p KVPrefix) GetProto(k []byte, m proto.Message) error

GetProto wraps Get, unmarshalling a retrieved proto into m

func (KVPrefix) List

func (p KVPrefix) List(prefix []byte) ([][]byte, error)

List keys matching a given prefix.

func (KVPrefix) Set

func (p KVPrefix) Set(k, b []byte) error

Set a value in the KV

func (KVPrefix) SetProto

func (p KVPrefix) SetProto(k []byte, m proto.Message) error

SetProto marshals a proto and sets it as a value in the KV

Jump to

Keyboard shortcuts

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