Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

memdb

v1.21.5
github.com/luxfi/database/heightindexdb/memdb

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

8 matches

Top ↑

Types

Database

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

Database is an in-memory implementation of HeightIndex. It provides thread-safe height-based key-value storage for testing and high-performance paths.

New

func New() *Database

New creates a new in-memory HeightIndex database.

Database.Close

func (db *Database) Close() error

Close releases resources and clears all stored data. Subsequent operations will return database.ErrClosed.

Database.Delete

func (db *Database) Delete(height uint64) error

Delete removes the value at the given height. Does not return an error if the height does not exist.

Database.Get

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

Get retrieves the value at the given height. Returns database.ErrNotFound if the height does not exist. The returned byte slice is safe to read, but cannot be modified.

Database.Has

func (db *Database) Has(height uint64) (bool, error)

Has returns whether a value exists at the given height.

Database.Put

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

Put inserts the value at the given height. The value is copied to prevent external mutation.

Dependency graph