memdb

package
v0.0.0-...-a7c0c5f Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: GPL-3.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryDB

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

MemoryDB is an in-memory implementation of the db.Database interface.

func New

func New() *MemoryDB

New creates a new MemoryDB instance.

func (*MemoryDB) Close

func (m *MemoryDB) Close() error

Close closes the database. For in-memory DB, it's a no-op.

func (*MemoryDB) Compact

func (m *MemoryDB) Compact() error

Compact is a no-op for in-memory DB.

func (*MemoryDB) Get

func (m *MemoryDB) Get(key []byte) ([]byte, error)

Get retrieves the value for the given key. If the key does not exist, returns ErrKeyNotFound.

func (*MemoryDB) Iterate

func (m *MemoryDB) Iterate(prefix []byte, callback func(key, value []byte) bool) error

Iterate calls the callback with all key-value pairs in the database whose key starts with prefix. The iteration is ordered lexicographically by key.

func (*MemoryDB) WriteTx

func (m *MemoryDB) WriteTx() db.WriteTx

WriteTx creates a new write transaction.

Jump to

Keyboard shortcuts

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