kvutil

package
v0.0.0-...-190fe23 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AscendGob

func AscendGob[T any](ctx context.Context, r kv.Ranger, beg, end string, errp *error) iter.Seq2[string, *T]

AscendGob iterates over all values in the input range unmarshaling the Gob encoded bytes into a value of type T. Returned value through the iterator is overwritten when the next key-value pair is visited.

func Backup

func Backup(ctx context.Context, db kv.Database, w io.Writer) error

Backup saves database content into the writer. Written data will be a consistent snapshot of the database.

func Clear

func Clear(ctx context.Context, db kv.Database, maxPerTx int64) error

Clear deletes all key-value pairs in the database. When maxPerTx is non-zero, operation is split into multiple transactions, with at most maxPerTx deletions in one transaction.

func DescendGob

func DescendGob[T any](ctx context.Context, r kv.Ranger, beg, end string, errp *error) iter.Seq2[string, *T]

DescendGob iterates over all values in the input range unmarshaling the Gob encoded bytes into a value of type T. Returned value through the iterator is overwritten when the next key-value pair is visited.

func GetGob

func GetGob(ctx context.Context, g kv.Getter, key string, value any) error

GetGob decodes the Gob encoded bytes at the key and returns as an object. Input value parameter must be of a pointer type.

func PrefixRange

func PrefixRange(dir string) (begin string, end string)

PrefixRange returns the begin and end keys that cover all keys with a given prefix.

func Restore

func Restore(ctx context.Context, db kv.Database, r io.Reader, maxPerTx int64) error

Restore updates the database with key-value content from the reader. When maxPerTx is non-zero, restore will happen in multiple transactions with at most maxPerTx updates in one transaction.

func SetGob

func SetGob(ctx context.Context, s kv.Setter, key string, value any) error

SetGob creates or updates the value at the key to Gob encoded bytes of the input value.

func ValidateBackup

func ValidateBackup(ctx context.Context, r io.Reader) error

ValidateBackup scans the database backup for checksum errors.

func WithReadWriter

func WithReadWriter(ctx context.Context, db kv.Database, work func(context.Context, kv.ReadWriter) error) error

WithReadWriter executes the work function within a temporary transaction, providing read-write access to the key-value store. The transaction is committed if the function returns nil; otherwise, it is rolled back.

Returns an error if creating the transaction, executing the function, or committing the transaction fails. The context controls cancellation and timeouts.

func WithReader

func WithReader(ctx context.Context, db kv.Database, work func(context.Context, kv.Reader) error) error

WithReader executes the work function within a temporary snapshot, ensuring read-only access to the key-value store. The snapshot is discarded after the function completes, regardless of the outcome.

Returns an error if creating the snapshot or executing the function fails. The context controls cancellation and timeouts.

Types

This section is empty.

Jump to

Keyboard shortcuts

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