db

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVDB

type KVDB interface {
	// Get returns the value for a key.
	Get(key []byte) ([]byte, error)

	// Put stores the value for a key.
	Put(key []byte, value []byte) error

	// Delete removes the value for a key.
	Delete(key []byte) error

	// Iterate iterates through a range of key-value pairs.
	Iterate(keyLB, keyUB []byte, done chan struct{}, callback func(key, value []byte)) error

	// Close gracefully shuts down the database.
	Close()
}

KVDB is the (thin) abstraction layer of an implementation-agnostic key-value store.

type Memory added in v0.3.0

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

Memory contains an in-memory KVDB.

func NewMemoryDB added in v0.3.0

func NewMemoryDB() *Memory

NewMemoryDB creates a new in-memory KVDB.

func (*Memory) Close added in v0.3.0

func (db *Memory) Close()

Close gracefully shuts down the database.

func (*Memory) Delete added in v0.3.0

func (db *Memory) Delete(key []byte) error

Delete removes the value for a key.

func (*Memory) Get added in v0.3.0

func (db *Memory) Get(key []byte) ([]byte, error)

Get returns the value for a key.

func (*Memory) Iterate added in v0.3.0

func (db *Memory) Iterate(
	keyLB, keyUB []byte, done chan struct{}, callback func(key, value []byte),
) error

Iterate iterates over the values in the DB.

func (*Memory) Put added in v0.3.0

func (db *Memory) Put(key []byte, value []byte) error

Put stores the value for a key.

type RocksDB

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

RocksDB implements the KVStore interface with a thinly wrapped RocksDB instance.

func NewRocksDB

func NewRocksDB(dbDir string) (*RocksDB, error)

NewRocksDB creates a new RocksDB instance with default read and write options.

func NewTempDirRocksDB

func NewTempDirRocksDB() (*RocksDB, func(), error)

NewTempDirRocksDB creates a new RocksDB instance (used mostly for local testing) in a local temporary directory.

func (*RocksDB) Close

func (db *RocksDB) Close()

Close gracefully shuts down the database.

func (*RocksDB) Delete

func (db *RocksDB) Delete(key []byte) error

Delete removes the value for a key.

func (*RocksDB) Get

func (db *RocksDB) Get(key []byte) ([]byte, error)

Get returns the value for a key.

func (*RocksDB) Iterate

func (db *RocksDB) Iterate(
	keyLB, keyUB []byte, done chan struct{}, callback func(key, value []byte),
) error

Iterate iterates over the values in the DB.

func (*RocksDB) Put

func (db *RocksDB) Put(key []byte, value []byte) error

Put stores the value for a key.

Jump to

Keyboard shortcuts

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