storage

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: LGPL-3.0 Imports: 1 Imported by: 10 modules, 15 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

This section is empty.

Variables

View Source
var (
	ErrorNotFound = fmt.Errorf("not found in DB")
)

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Put(key, value []byte)
	Delete(key []byte)
	Commit()
}

type Iterator

type Iterator interface {
	// Next moves the iterator to the next key/value pair.
	// It returns false if the iterator is exhausted.
	Next() bool

	// Prev moves the iterator to the previous key/value pair.
	// It returns false if the iterator is exhausted.
	Prev() bool

	// Seek moves the iterator to the first key/value pair whose key is greater
	// than or equal to the given key.
	// It returns whether such pair exist.
	//
	// It is safe to modify the contents of the argument after Seek returns.
	Seek(key []byte) bool

	// Key returns the key of the current key/value pair, or nil if done.
	Key() []byte

	// Value returns the value of the current key/value pair, or nil if done.
	Value() []byte
}

type Storage

type Storage interface {
	Write

	// Get retrieves the object `value` named by `key`.
	// Get will return nil if the key is not mapped to a value.
	Get(key []byte) []byte

	// Has returns whether the `key` is mapped to a `value`.
	Has(key []byte) bool

	// Iterator iterates over a DB's key/value pairs in key order.
	Iterator(start, end []byte) Iterator

	// Prefix iterates over a DB's key/value pairs in key order including prefix.
	Prefix(prefix []byte) Iterator

	NewBatch() Batch

	Close() error

	// GetStats return database statistics
	GetStats() (interface{}, error)
}

type Write

type Write interface {
	// Put stores the object `value` named by `key`.
	Put(key, value []byte)

	// Delete removes the value for given `key`.
	Delete(key []byte)
}

Write is the write-side of the storage interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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