Documentation
¶
Index ¶
- func AscendGob[T any](ctx context.Context, r kv.Ranger, beg, end string, errp *error) iter.Seq2[string, *T]
- func Backup(ctx context.Context, db kv.Database, w io.Writer) error
- func Clear(ctx context.Context, db kv.Database, maxPerTx int64) error
- func DescendGob[T any](ctx context.Context, r kv.Ranger, beg, end string, errp *error) iter.Seq2[string, *T]
- func GetGob(ctx context.Context, g kv.Getter, key string, value any) error
- func PrefixRange(dir string) (begin string, end string)
- func Restore(ctx context.Context, db kv.Database, r io.Reader, maxPerTx int64) error
- func SetGob(ctx context.Context, s kv.Setter, key string, value any) error
- func ValidateBackup(ctx context.Context, r io.Reader) error
- func WithReadWriter(ctx context.Context, db kv.Database, ...) error
- func WithReader(ctx context.Context, db kv.Database, ...) error
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 ¶
Backup saves database content into the writer. Written data will be a consistent snapshot of the database.
func Clear ¶
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 ¶
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 ¶
PrefixRange returns the begin and end keys that cover all keys with a given prefix.
func Restore ¶
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 ¶
SetGob creates or updates the value at the key to Gob encoded bytes of the input value.
func ValidateBackup ¶
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.