leveldbhelper

package
v1.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: Apache-2.0 Imports: 9 Imported by: 2,584

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	DBPath string
}

Conf configuration for `DB`

type DB

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

DB - a wrapper on an actual store

func CreateDB

func CreateDB(conf *Conf) *DB

CreateDB constructs a `DB`

func (*DB) Close

func (dbInst *DB) Close()

Close closes the underlying db

func (*DB) Delete

func (dbInst *DB) Delete(key []byte, sync bool) error

Delete deletes the given key

func (*DB) Get

func (dbInst *DB) Get(key []byte) ([]byte, error)

Get returns the value for the given key

func (*DB) GetIterator

func (dbInst *DB) GetIterator(startKey []byte, endKey []byte) iterator.Iterator

GetIterator returns an iterator over key-value store. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key

func (*DB) Open

func (dbInst *DB) Open()

Open opens the underlying db

func (*DB) Put

func (dbInst *DB) Put(key []byte, value []byte, sync bool) error

Put saves the key/value

func (*DB) WriteBatch

func (dbInst *DB) WriteBatch(batch *leveldb.Batch, sync bool) error

WriteBatch writes a batch

type DBHandle

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

DBHandle is an handle to a named db

func (*DBHandle) Delete

func (h *DBHandle) Delete(key []byte, sync bool) error

Delete deletes the given key

func (*DBHandle) Get

func (h *DBHandle) Get(key []byte) ([]byte, error)

Get returns the value for the given key

func (*DBHandle) GetIterator

func (h *DBHandle) GetIterator(startKey []byte, endKey []byte) *Iterator

GetIterator gets an handle to iterator. The iterator should be released after the use. The resultset contains all the keys that are present in the db between the startKey (inclusive) and the endKey (exclusive). A nil startKey represents the first available key and a nil endKey represent a logical key after the last available key

func (*DBHandle) Put

func (h *DBHandle) Put(key []byte, value []byte, sync bool) error

Put saves the key/value

func (*DBHandle) WriteBatch

func (h *DBHandle) WriteBatch(batch *UpdateBatch, sync bool) error

WriteBatch writes a batch in an atomic way

type Iterator

type Iterator struct {
	iterator.Iterator
}

Iterator extends actual leveldb iterator

func (*Iterator) Key

func (itr *Iterator) Key() []byte

Key wraps actual leveldb iterator method

type Provider

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

Provider enables to use a single leveldb as multiple logical leveldbs

func NewProvider

func NewProvider(conf *Conf) *Provider

NewProvider constructs a Provider

func (*Provider) Close

func (p *Provider) Close()

Close closes the underlying leveldb

func (*Provider) GetDBHandle

func (p *Provider) GetDBHandle(dbName string) *DBHandle

GetDBHandle returns a handle to a named db

type UpdateBatch

type UpdateBatch struct {
	KVs map[string][]byte
}

UpdateBatch encloses the details of multiple `updates`

func NewUpdateBatch

func NewUpdateBatch() *UpdateBatch

NewUpdateBatch constructs an instance of a Batch

func (*UpdateBatch) Delete

func (batch *UpdateBatch) Delete(key []byte)

Delete deletes a Key and associated value

func (*UpdateBatch) Put

func (batch *UpdateBatch) Put(key []byte, value []byte)

Put adds a KV

Jump to

Keyboard shortcuts

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