lvldb

package
v0.0.0-...-75aef46 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: GPL-3.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LevelDB

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

LevelDB wraps level db impls.

func New

func New(path string, opts Options) (*LevelDB, error)

New create a persistent level db instance. Create an empty one if not exists, or open if already there.

func NewMem

func NewMem() (*LevelDB, error)

NewMem create a level db in memory.

func (*LevelDB) Close

func (ldb *LevelDB) Close() error

Close close the level db. Later operations will all fail.

func (*LevelDB) Delete

func (ldb *LevelDB) Delete(key []byte) error

Delete deletes the give key and its value.

func (*LevelDB) Get

func (ldb *LevelDB) Get(key []byte) (value []byte, err error)

Get retrieve value for given key. It returns an error if key not found. The error can be checked via IsNotFound.

func (*LevelDB) Has

func (ldb *LevelDB) Has(key []byte) (bool, error)

Has returns whether a key exists.

func (*LevelDB) IsNotFound

func (ldb *LevelDB) IsNotFound(err error) bool

IsNotFound to check if the error returned by Get indicates key not found.

func (*LevelDB) NewBatch

func (ldb *LevelDB) NewBatch() kv.Batch

NewBatch create a batch for writing ops.

func (*LevelDB) NewIterator

func (ldb *LevelDB) NewIterator(r kv.Range) kv.Iterator

NewIterator create a iterator by range.

func (*LevelDB) Put

func (ldb *LevelDB) Put(key, value []byte) error

Put save value fo give key.

type Options

type Options struct {
	CacheSize              int
	OpenFilesCacheCapacity int
}

Options options for creating level db instance.

Jump to

Keyboard shortcuts

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