memory

package
v1.2.10-rc.7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeSet

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

ChangeSet is a key-value change set.

func NewChangeSet

func NewChangeSet(prefix *record.Key, get GetFunc, commit CommitFunc, discard DiscardFunc) *ChangeSet

func (*ChangeSet) Begin

func (c *ChangeSet) Begin(prefix *record.Key, writable bool) keyvalue.ChangeSet

Begin begins a nested change set.

func (*ChangeSet) Commit

func (c *ChangeSet) Commit() error

Commit commits pending changes to the parent store.

func (*ChangeSet) Delete

func (c *ChangeSet) Delete(key *record.Key) error

Delete deletes a key-value pair.

func (*ChangeSet) Discard

func (c *ChangeSet) Discard()

Discard discards pending changes.

func (*ChangeSet) Get

func (c *ChangeSet) Get(key *record.Key) ([]byte, error)

Get loads a value.

func (*ChangeSet) Put

func (c *ChangeSet) Put(key *record.Key, value []byte) error

Put stores a value.

type CommitFunc

type CommitFunc = func(map[[32]byte]Entry) error

type Database

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

func New

func New(prefix *record.Key) *Database

func (*Database) Begin

func (d *Database) Begin(prefix *record.Key, writable bool) keyvalue.ChangeSet

Begin begins a change set.

func (*Database) Export

func (d *Database) Export() ([]Entry, error)

Export exports the database as a set of entries. Behavior is undefined if the database was created with a prefix. Export may return an error in the future. Export is not safe to use concurrently.

func (*Database) Import

func (d *Database) Import(entries []Entry) error

Import imports a set of entries into the database. Behavior is undefined if the database was created with a prefix. Import is not safe to use concurrently.

type DiscardFunc added in v1.2.10

type DiscardFunc = func()

type Entry

type Entry struct {
	Key    *record.Key
	Value  []byte
	Delete bool
}

Entry is a ChangeSet entry.

type GetFunc

type GetFunc = func(*record.Key) ([]byte, error)

Jump to

Keyboard shortcuts

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