kv

package
v0.0.0-...-2eec6a9 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2017 License: LGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package kv provides key-value based storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	Writer

	// Reset clear pending operations.
	Reset()

	// Write flush pending operations.
	// It will not clear pending operations.
	Write() error

	// Len returns pending operations count.
	Len() int
}

Batch interface of batched operation.

type Iterator

type Iterator interface {
	First() bool
	Last() bool
	Seek(key []byte) bool
	Next() bool
	Prev() bool

	Release()

	Error() error

	Key() []byte
	Value() []byte
}

Iterator see iterator in leveldb.

type OptValue

type OptValue struct {
	V []byte
}

type Options

type Options struct {
	CacheSize              int
	OpenFilesCacheCapacity int
}

Options options to initialize store

type Range

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

Range describes key range of kv store.

func NewRange

func NewRange(from []byte, to []byte) *Range

NewRange create a range.

func NewRangeWithBytesPrefix

func NewRangeWithBytesPrefix(prefix []byte) *Range

NewRangeWithBytesPrefix create a range defined by bytes prefix.

func NewRangeWithHexPrefix

func NewRangeWithHexPrefix(hexPrefix string) (*Range, error)

NewRangeWithHexPrefix create a range defined by hex prefix. The hex can be odd.

type Reader

type Reader interface {
	// Has returns whether a key exists
	Has(key []byte) (bool, error)

	// Get retrieve value for the given key.
	Get(key []byte) (*OptValue, error)
}

Reader kv reading methods

type Store

type Store interface {
	Reader
	Writer

	// NewBatch create batch object for batch writes.
	NewBatch() Batch

	// NewIterator create iterator to iterates kv pairs for the given range.
	NewIterator(r *Range) Iterator

	// Close close the store.
	Close() error
}

Store interface of key-value storage.

func NewMemStore

func NewMemStore(options Options) (Store, error)

NewMemStore create kv store in memory, for test purpose

func NewStore

func NewStore(filePath string, options Options) (Store, error)

NewStore create/open kv store at specified file path.

type Writer

type Writer interface {
	// Put store value for the given key.
	Put(key []byte, value []byte) error

	// Delete delete value for the given key.
	Delete(key []byte) error
}

Writer kv writing methods

Jump to

Keyboard shortcuts

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