memdb

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: BSD-3-Clause Imports: 6 Imported by: 5

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) 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) 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.

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