leveldb

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

func New

func New(file string, cache int, handles int, readonly bool) (*Database, error)

New returns a wrapped LevelDB object. The namespace is the prefix that the datastore.

func NewCustom

func NewCustom(file string, namespace string, customize func(options *opt.Options)) (*Database, error)

NewCustom returns a wrapped LevelDB object. The namespace is the prefix that the datastore. The customize function allows the caller to modify the leveldb options.

func NewFromExistLevelDB

func NewFromExistLevelDB(db *leveldb.DB) *Database

NewFromExistLevelDB returns a wrapped LevelDB object.

func WrapWithNamespace

func WrapWithNamespace(db *Database, namespace string) *Database

WrapWithNamespace returns a wrapped LevelDB object. The namespace is the prefix that the datastore.

func (*Database) Close

func (db *Database) Close() error

Close flushes any pending data to disk and closes all io accesses to the underlying key-value store.

func (*Database) Delete

func (db *Database) Delete(key []byte) error

Delete removes the key from the key-value store.

func (*Database) Get

func (db *Database) Get(key []byte) ([]byte, error)

Get retrieves the given key if it's present in the key-value store.

func (*Database) Has

func (db *Database) Has(key []byte) (bool, error)

Has retrieves if a key is present in the key-value store.

func (*Database) NewBatch

func (db *Database) NewBatch() database.Batcher

NewBatch creates a write-only key-value store that buffers changes to its host database until a final write is called.

func (*Database) Set

func (db *Database) Set(key []byte, value []byte) error

Put inserts the given value into the key-value store.

Jump to

Keyboard shortcuts

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