lvldb

package
v1.2.0-fork7 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: LGPL-3.0 Imports: 7 Imported by: 1

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) Compact

func (ldb *LevelDB) Compact(start []byte, limit []byte) error

Compact flattens the underlying data store for the given key range. In essence, deleted and overwritten versions are discarded, and the data is rearranged to reduce the cost of operations needed to access them.

A nil start is treated as a key before all keys in the data store; a nil limit is treated as a key after all keys in the data store. If both is nil then it will compact entire data store.

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.

func (*LevelDB) Stat

func (ldb *LevelDB) Stat(property string) (string, error)

Stat returns a particular internal stat of the database.

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