memory

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 6 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(opts ChangeSetOptions) *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) ForEach added in v1.4.0

func (c *ChangeSet) ForEach(fn func(*record.Key, []byte) error) error

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 ChangeSetOptions added in v1.4.0

type ChangeSetOptions struct {
	Prefix  *record.Key // Prefix to apply to keys
	Get     GetFunc     // Gets an entry from the previous layer
	Commit  CommitFunc  // Commits changes into the previous layer
	ForEach ForEachFunc // Iterates over each entry
	Discard DiscardFunc // Cleans up after discard
}

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 ForEachFunc added in v1.4.0

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

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