memdb

package
v1.18.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: BSD-3-Clause Imports: 8 Imported by: 8 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultSize is the default initial size of the database.
	DefaultSize = 1 << 10
)
View Source
const Name = "memdb"

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

Database is an in-memory implementation of db.Database.

func New

func New() *Database

New returns a new in-memory database.

func NewFromMap

func NewFromMap(m map[string][]byte) *Database

NewFromMap returns a new in-memory database initialized with the provided map.

func NewWithSize

func NewWithSize(size int) *Database

NewWithSize returns a new in-memory database with the specified initial size.

func (*Database) AtomicClear

func (db *Database) AtomicClear(newSize int) error

AtomicClear clears the database atomically.

func (*Database) AtomicWrite

func (db *Database) AtomicWrite(ctx context.Context, ops map[string][]byte) error

AtomicWrite writes all the key-value pairs atomically.

func (*Database) Backup added in v1.5.1

func (db *Database) Backup(io.Writer, uint64) (uint64, error)

func (*Database) Close

func (db *Database) Close() error

Close implements db.Database.

func (*Database) Compact

func (db *Database) Compact(start []byte, limit []byte) error

Compact implements db.Database.

func (*Database) Delete

func (db *Database) Delete(key []byte) error

Delete implements db.Database.

func (*Database) Get

func (db *Database) Get(key []byte) ([]byte, error)

Get implements db.Database.

func (*Database) GetDatabase

func (db *Database) GetDatabase() map[string][]byte

GetDatabase returns the underlying database map. This should only be used for testing.

func (*Database) Has

func (db *Database) Has(key []byte) (bool, error)

Has implements db.Database.

func (*Database) HealthCheck

func (db *Database) HealthCheck(ctx context.Context) (interface{}, error)

HealthCheck implements db.Database.

func (*Database) Load added in v1.5.1

func (db *Database) Load(io.Reader) error

func (*Database) NewBatch

func (db *Database) NewBatch() database.Batch

NewBatch implements db.Database.

func (*Database) NewIterator

func (db *Database) NewIterator() database.Iterator

NewIterator implements db.Database.

func (*Database) NewIteratorWithPrefix

func (db *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator

NewIteratorWithPrefix implements db.Database.

func (*Database) NewIteratorWithStart

func (db *Database) NewIteratorWithStart(start []byte) database.Iterator

NewIteratorWithStart implements db.Database.

func (*Database) NewIteratorWithStartAndPrefix

func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator

NewIteratorWithStartAndPrefix implements db.Database.

func (*Database) Put

func (db *Database) Put(key []byte, value []byte) error

Put implements db.Database.

func (*Database) SetDatabase

func (db *Database) SetDatabase(m map[string][]byte)

SetDatabase sets the underlying database map. This should only be used for testing.

func (*Database) Sync added in v1.2.17

func (db *Database) Sync() error

Sync implements db.Database. For memdb, this is a no-op since all data is in memory.

type IteratorError

type IteratorError struct {
	Err error
}

IteratorError is a wrapper for iterator errors

func (*IteratorError) Error

func (i *IteratorError) Error() error

func (*IteratorError) Key

func (i *IteratorError) Key() []byte

func (*IteratorError) Next

func (i *IteratorError) Next() bool

func (*IteratorError) Release

func (i *IteratorError) Release()

func (*IteratorError) Value

func (i *IteratorError) Value() []byte

Jump to

Keyboard shortcuts

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