leveldb

package
v1.7.11-rc.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: BSD-3-Clause Imports: 12 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// Name is the name of this database for database switches
	Name = "leveldb"

	// BlockCacheSize is the number of bytes to use for block caching in
	// leveldb.
	BlockCacheSize = 12 * opt.MiB

	// WriteBufferSize is the number of bytes to use for buffers in leveldb.
	WriteBufferSize = 12 * opt.MiB

	// HandleCap is the number of files descriptors to cap levelDB to use.
	HandleCap = 1024

	// BitsPerKey is the number of bits to add to the bloom filter per key.
	BitsPerKey = 10
)

Variables

This section is empty.

Functions

func New

func New(file string, configBytes []byte, log logging.Logger) (database.Database, error)

New returns a wrapped LevelDB object.

Types

type Database

type Database struct {
	*leveldb.DB
	// contains filtered or unexported fields
}

Database is a persistent key-value store. Apart from basic data storage functionality it also supports batch writes and iterating over the keyspace in binary-alphabetical order.

func (*Database) Close

func (db *Database) Close() error

func (*Database) Compact

func (db *Database) Compact(start []byte, limit []byte) error

Compact the underlying DB for the given key range. Specifically, deleted and overwritten versions are discarded, and the data is rearranged to reduce the cost of operations needed to access the data. This operation should typically only be invoked by users who understand the underlying implementation.

A nil start is treated as a key before all keys in the DB. And a nil limit is treated as a key after all keys in the DB. Therefore if both are nil then it will compact entire DB.

func (*Database) Delete

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

Delete removes the key from the database

func (*Database) Get

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

Get returns the value the key maps to in the database

func (*Database) Has

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

Has returns if the key is set in the database

func (*Database) NewBatch

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

NewBatch creates a write/delete-only buffer that is atomically committed to the database when write is called

func (*Database) NewIterator

func (db *Database) NewIterator() database.Iterator

NewIterator creates a lexicographically ordered iterator over the database

func (*Database) NewIteratorWithPrefix

func (db *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator

NewIteratorWithPrefix creates a lexicographically ordered iterator over the database ignoring keys that do not start with the provided prefix

func (*Database) NewIteratorWithStart

func (db *Database) NewIteratorWithStart(start []byte) database.Iterator

NewIteratorWithStart creates a lexicographically ordered iterator over the database starting at the provided key

func (*Database) NewIteratorWithStartAndPrefix

func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator

NewIteratorWithStartAndPrefix creates a lexicographically ordered iterator over the database starting at start and ignoring keys that do not start with the provided prefix

func (*Database) Put

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

Put sets the value of the provided key to the provided value

func (*Database) Stat

func (db *Database) Stat(property string) (string, error)

Stat returns a particular internal stat of the database.

Jump to

Keyboard shortcuts

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