kvmemdb

package module
v0.0.0-...-8b180c2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

func New

func New() *Database

New creates an empty in-memory database.

func (*Database) NewSnapshot

func (d *Database) NewSnapshot(ctx context.Context) (*Snapshot, error)

NewSnapshot creates a read-only snapshot of the database.

func (*Database) NewTransaction

func (d *Database) NewTransaction(ctx context.Context) (*Transaction, error)

NewTransaction creates a read-write transaction on the database.

type Snapshot

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

func (*Snapshot) Ascend

func (s *Snapshot) Ascend(ctx context.Context, begin, end string, errp *error) iter.Seq2[string, io.Reader]

Ascend implements kv.Scanner interface to range over key-value pairs between 'begin' and 'end' keys in the database in ascending order.

func (*Snapshot) Descend

func (s *Snapshot) Descend(ctx context.Context, begin, end string, errp *error) iter.Seq2[string, io.Reader]

Ascend implements kv.Scanner interface to range over key-value pairs between 'begin' and 'end' keys in the database in descending order.

func (*Snapshot) Discard

func (s *Snapshot) Discard(ctx context.Context) error

Discard releases the snapshot.

func (*Snapshot) Get

func (s *Snapshot) Get(ctx context.Context, key string) (io.Reader, error)

Get returns the value associated with the input key. Returns os.ErrNotExist if key was deleted or doesn't exist.

func (*Snapshot) Scan

func (s *Snapshot) Scan(ctx context.Context, errp *error) iter.Seq2[string, io.Reader]

Scan implements kv.Scanner interface to range over all key-value pairs in the database.

type Transaction

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

func (*Transaction) Ascend

func (t *Transaction) Ascend(ctx context.Context, begin, end string, errp *error) iter.Seq2[string, io.Reader]

Ascend implements kv.Scanner interface to range over key-value pairs between 'begin' and 'end' keys in the database in ascending order.

func (*Transaction) Commit

func (t *Transaction) Commit(ctx context.Context) error

Commit attempts to save all updates performed by the transaction to the database. Returns nil on success. Transaction is effectively destroyed irrespective of the result and no operations should be performed any further.

func (*Transaction) Delete

func (t *Transaction) Delete(ctx context.Context, key string) error

Delete removes the input key and the associated value. Returns nil even when the input key doesn't exist.

func (*Transaction) Descend

func (t *Transaction) Descend(ctx context.Context, begin, end string, errp *error) iter.Seq2[string, io.Reader]

Ascend implements kv.Scanner interface to range over key-value pairs between 'begin' and 'end' keys in the database in descending order.

func (*Transaction) Get

func (t *Transaction) Get(ctx context.Context, key string) (io.Reader, error)

Get returns the value associated with the input key. Returns os.ErrNotExist if key was deleted or doesn't exist.

func (*Transaction) Rollback

func (t *Transaction) Rollback(ctx context.Context) error

Rollback drops all updates performed by the transaction. Transaction is effectively destroyed and no operations should be performed any further.

func (*Transaction) Scan

func (t *Transaction) Scan(ctx context.Context, errp *error) iter.Seq2[string, io.Reader]

Scan implements kv.Scanner interface to range over all key-value pairs in the database.

func (*Transaction) Set

func (t *Transaction) Set(ctx context.Context, key string, value io.Reader) error

Set creates or updates a key-value pair in the database. The input key cannot be empty and input value cannot be nil.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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