kvstore

package
v0.0.0-...-d3d27b2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorNotFound = leveldb.ErrNotFound

ErrorNotFound signal error for not found

Functions

This section is empty.

Types

type KVIterator

type KVIterator interface {
	Key() string
	Value() []byte
	ValueJSON(obj interface{}) error
	Next() bool
	Prev() bool
	Seek(string) bool
	Last() bool
	Release()
}

KVIterator interface for key value iterators

type KVStore

type KVStore interface {
	Put(key string, val []byte) error
	PutJSON(key string, val interface{}) error
	Get(key string) ([]byte, error)
	GetJSON(key string, obj interface{}) error
	Delete(key string) error
	NewIterator() KVIterator
	NewIteratorWithRange(keyRange *Range) KVIterator
	Close()
}

KVStore interface for key value stores

func NewLDBKeyValueStore

func NewLDBKeyValueStore(ldbPath string) (kv KVStore, err error)

NewLDBKeyValueStore construct a new LevelDB instance of a KV store

type MockKV

type MockKV struct {
	KVS       map[string][]byte
	StoreErr  error
	LoadErr   error
	DeleteErr error
}

MockKV simple memory K/V store for testing

func NewMockKV

func NewMockKV(err error) *MockKV

NewMockKV constructor

func (*MockKV) Close

func (m *MockKV) Close()

Close it

func (*MockKV) Delete

func (m *MockKV) Delete(key string) error

Delete a key

func (*MockKV) Get

func (m *MockKV) Get(key string) ([]byte, error)

Get a key

func (*MockKV) GetJSON

func (m *MockKV) GetJSON(key string, obj interface{}) error

Get a key as object

func (*MockKV) NewIterator

func (m *MockKV) NewIterator() KVIterator

NewIterator for a new iterator

func (*MockKV) NewIteratorWithRange

func (m *MockKV) NewIteratorWithRange(rng *Range) KVIterator

NewIterator for a new iterator

func (*MockKV) Put

func (m *MockKV) Put(key string, val []byte) error

Put a key

func (*MockKV) PutJSON

func (m *MockKV) PutJSON(key string, obj interface{}) error

PutJSON an object

type Range

type Range = util.Range

Jump to

Keyboard shortcuts

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