leveldb

package
v0.0.0-...-fb9d71b Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package leveldb implements the key-value database interface using LevelDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

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

Batch represents a batch and implements the batch interface.

func (*Batch) Apply

func (b *Batch) Apply() error

Apply applies the batch to the database.

func (*Batch) Delete

func (b *Batch) Delete(key string) error

Delete deletes a value from the batch.

func (*Batch) Put

func (b *Batch) Put(key string, value string) error

Put puts a new value in the batch.

func (*Batch) PutBytes

func (b *Batch) PutBytes(key string, value []byte) error

PutBytes puts a new byte slice into the batch.

func (*Batch) Reset

func (b *Batch) Reset()

Reset resets the batch.

type Database

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

Database implements the Database interface and stores the values in memory.

func LoadDatabase

func LoadDatabase(path string) (*Database, error)

LoadDatabase creates a new, empty Database.

func (*Database) Delete

func (d *Database) Delete(key string) error

Delete removes the key from the key-value store. If the key is not present, an error is returned.

func (*Database) Get

func (d *Database) Get(key string) (string, error)

Get returns the value as string for given key if it is present in the store.

func (*Database) GetBytes

func (d *Database) GetBytes(key string) ([]byte, error)

GetBytes returns the value as []byte for given key if it is present in the store.

func (*Database) Has

func (d *Database) Has(key string) (bool, error)

Has returns true iff the memorydb contains a key.

func (*Database) NewBatch

func (d *Database) NewBatch() sortedkv.Batch

NewBatch creates a new batch.

func (*Database) NewIterator

func (d *Database) NewIterator() sortedkv.Iterator

NewIterator creates a new iterator.

func (*Database) NewIteratorWithPrefix

func (d *Database) NewIteratorWithPrefix(prefix string) sortedkv.Iterator

NewIteratorWithPrefix creates a new iterator for a given prefix.

func (*Database) NewIteratorWithRange

func (d *Database) NewIteratorWithRange(start string, end string) sortedkv.Iterator

NewIteratorWithRange creates a new iterator based on a given range.

func (*Database) Put

func (d *Database) Put(key string, value string) error

Put inserts the given value into the key-value store. If the key is already present, it is overwritten and no error is returned.

func (*Database) PutBytes

func (d *Database) PutBytes(key string, value []byte) error

PutBytes inserts the given value into the key-value store. If the key is already present, it is overwritten and no error is returned.

type Iterator

type Iterator struct {
	iterator.Iterator
	// contains filtered or unexported fields
}

Iterator provides an iterator over a key range.

func (*Iterator) Close

func (i *Iterator) Close() error

Close closes this iterator.

func (*Iterator) Key

func (i *Iterator) Key() string

Key returns the key of the current element.

func (*Iterator) Next

func (i *Iterator) Next() bool

Next returns true if the iterator has a next element.

func (*Iterator) Value

func (i *Iterator) Value() string

Value returns the value of the current element.

func (*Iterator) ValueBytes

func (i *Iterator) ValueBytes() []byte

ValueBytes returns the value converted to bytes of the current element.

Jump to

Keyboard shortcuts

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