kvstore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package kvstore defines a shared, minimal key/value store API used across gomap engines (HashDB, TreeDB, BTreeOnHashDB) and tooling like cmd/unified_bench.

Iterator semantics (performance-first):

  • Key() and Value() may return read-only views into underlying storage.
  • Returned slices are valid until the next Next()/Close() call on that iterator.
  • Callers must not modify returned slices; use KeyCopy/ValueCopy for stable bytes.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("kvstore: unsupported")

ErrUnsupported is returned by optional capabilities that are not implemented by a particular engine (e.g. ordered iteration for HashDB).

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Set(key, value []byte) error
	Delete(key []byte) error
	Commit() error
	CommitSync() error
	Close() error
}

Batch is a buffered write unit.

type Batcher

type Batcher interface {
	NewBatch() (Batch, error)
}

Batcher is an optional capability for batched writes.

type DB

type DB interface {
	Name() string
	Close() error

	Get(key []byte) ([]byte, error)
	Set(key, value []byte) error
	Delete(key []byte) error
}

DB is the minimal common interface shared across all engines.

type ForEacher

type ForEacher interface {
	ForEach(func(key, value []byte) error) error
}

ForEacher is an optional capability for visiting all live key/value pairs. Iteration order is engine-defined and may be arbitrary.

type Haser

type Haser interface {
	Has(key []byte) (bool, error)
}

Haser is an optional capability for checking existence without retrieving values.

type Iterator

type Iterator interface {
	Valid() bool
	Next()

	Key() []byte
	Value() []byte
	KeyCopy(dst []byte) []byte
	ValueCopy(dst []byte) []byte

	Error() error
	Close() error
}

Iterator is a forward-only iterator over key/value pairs.

type Printer

type Printer interface {
	Print() error
}

Printer is an optional capability for debug printing.

type RangeScanner

type RangeScanner interface {
	Iterator(start, end []byte) (Iterator, error)
	ReverseIterator(start, end []byte) (Iterator, error)
}

RangeScanner is an optional capability for ordered iteration over a key domain. Start is inclusive, End is exclusive; nil means unbounded.

type StatsProvider

type StatsProvider interface {
	Stats() map[string]string
}

StatsProvider is an optional capability for exposing engine stats.

type Syncer

type Syncer interface {
	SetSync(key, value []byte) error
	DeleteSync(key []byte) error
}

Syncer is an optional capability for durability-oriented writes.

Directories

Path Synopsis
adapters

Jump to

Keyboard shortcuts

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