memdb

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemDB

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

MemDB is an in-memory database backend using a B-tree for storage.

For performance reasons, all given and returned keys and values are pointers to the in-memory database, so modifying them will cause the stored values to be modified as well. All DB methods already specify that keys and values should be considered read-only, but this is especially important with MemDB.

Versioning is implemented by maintaining references to copy-on-write clones of the backing btree.

Note: Currently, transactions do not detect write conflicts, so multiple writers cannot be safely committed to overlapping domains. Because of this, the number of open writers is limited to 1.

func NewDB

func NewDB() *MemDB

NewDB creates a new in-memory database.

func (*MemDB) Close

func (dbm *MemDB) Close() error

Close implements DB. Close is a noop since for an in-memory database, we don't have a destination to flush contents to nor do we want any data loss on invoking Close(). See the discussion in https://github.com/tendermint/tendermint/libs/pull/56

func (*MemDB) DeleteVersion

func (dbm *MemDB) DeleteVersion(target uint64) error

DeleteVersion implements DBConnection.

func (*MemDB) Print

func (dbm *MemDB) Print() error

Print prints the database contents.

func (*MemDB) ReadWriter

func (dbm *MemDB) ReadWriter() db.DBReadWriter

ReadWriter implements DBConnection.

func (*MemDB) Reader

func (dbm *MemDB) Reader() db.DBReader

Reader implements DBConnection.

func (*MemDB) ReaderAt

func (dbm *MemDB) ReaderAt(version uint64) (db.DBReader, error)

ReaderAt implements DBConnection.

func (*MemDB) Revert

func (dbm *MemDB) Revert() error

func (*MemDB) SaveNextVersion

func (dbm *MemDB) SaveNextVersion() (uint64, error)

SaveVersion implements DBConnection.

func (*MemDB) SaveVersion

func (dbm *MemDB) SaveVersion(target uint64) error

SaveNextVersion implements DBConnection.

func (*MemDB) Stats

func (dbm *MemDB) Stats() map[string]string

Stats implements DBConnection.

func (*MemDB) Versions

func (dbm *MemDB) Versions() (db.VersionSet, error)

Versions implements DBConnection.

func (*MemDB) Writer

func (dbm *MemDB) Writer() db.DBWriter

Writer implements DBConnection.

Jump to

Keyboard shortcuts

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