leveldb

package
v0.0.0-...-4502c18 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte, obj interface{}) error

Types

type Batch

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

Batch is some kind of temporary storage in RAM. Once you perform a series of operations, call the Write() method to unload information from the batch into the database.

func (*Batch) CreateTableBatch

func (b *Batch) CreateTableBatch(prefix []byte) Batcher

CreateTableBatch creates new tablebatch instance.

func (*Batch) Delete

func (b *Batch) Delete(key []byte) error

Delete deletes value by key from the batch.

func (*Batch) Put

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

Put puts bytes to the batch.

func (*Batch) PutObject

func (b *Batch) PutObject(key []byte, obj interface{}) error

PutObject puts object to the batch.

func (*Batch) Reset

func (b *Batch) Reset()

Reset resets batch.

func (*Batch) Write

func (b *Batch) Write() error

Write writes data from batch to the database.

type Batcher

type Batcher interface {
	// Put puts bytes to the batch.
	Put(key, value []byte) error

	// PutObject puts object to the batch.
	PutObject(key []byte, obj interface{}) error

	// Delete deletes value by key from the batch.
	Delete(key []byte) error

	// Write writes data from batch to the database
	Write() error

	// Reset resets batch.
	Reset()

	// CreateTableBatch creates new tablebatch instance.
	CreateTableBatch(prefix []byte) Batcher
}

Batcher is a general representation of the batch, which can both tablebatch and batch.

type Corrector

type Corrector interface {
	// Put puts bytes to the database.
	Put(key, value []byte) error

	// PutObject puts object to the database.
	PutObject(key []byte, obj interface{}) error

	// Delete deletes value by key from the database.
	Delete(key []byte) error

	// Get gets bytes from the database.
	Get(key []byte) ([]byte, error)

	// GetObject gets object from the database.
	GetObject(key []byte, obj interface{}) error

	// Has checks the presence of an element in the database.
	Has(key []byte) (bool, error)
}

Corrector is a combination of Reader and Writer.

type Db

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

Db is wrapper over the standard leveldb.DB.

func Open

func Open(filepath string) *Db

Open opens a new connection to the database.

func (*Db) Close

func (db *Db) Close()

Close closes connection to the database.

func (*Db) CreateTable

func (db *Db) CreateTable(prefix []byte) *Tbl

CreateTable creates new table instance.

func (*Db) Delete

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

Delete deletes value by key from the database.

func (*Db) Get

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

Get gets bytes from the database.

func (*Db) GetObject

func (db *Db) GetObject(key []byte, obj interface{}) error

GetObject gets object from the database.

func (*Db) Has

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

Has checks the presence of an element in the database.

func (*Db) NewBatch

func (db *Db) NewBatch() *Batch

NewBatch creates new batch instance.

func (*Db) NewIterator

func (db *Db) NewIterator() iterator.Iterator

NewIterator creates new iterator instance.

func (*Db) NewIteratorPrefix

func (db *Db) NewIteratorPrefix(prefix []byte) iterator.Iterator

NewIteratorPrefix creates new iterator instance with prefix.

func (*Db) Put

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

Put puts bytes to the database.

func (*Db) PutObject

func (db *Db) PutObject(key []byte, obj interface{}) error

PutObject puts object to the database.

type Reader

type Reader interface {
	// Get gets bytes from the database.
	Get(key []byte) ([]byte, error)

	// GetObject gets object from the database.
	GetObject(key []byte, obj interface{}) error

	// Has checks the presence of an element in the database.
	Has(key []byte) (bool, error)
}

Reader is a database object with read access.

type Tbl

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

Tbl will in fact add a prefix to any records.

func (*Tbl) Delete

func (t *Tbl) Delete(key []byte) error

Delete deletes value by key from the table.

func (*Tbl) Get

func (t *Tbl) Get(key []byte) ([]byte, error)

Get gets bytes from the table.

func (*Tbl) GetObject

func (t *Tbl) GetObject(key []byte, obj interface{}) error

GetObject gets object from the table.

func (*Tbl) Has

func (t *Tbl) Has(key []byte) (bool, error)

Has checks the presence of an element in the table.

func (*Tbl) Put

func (t *Tbl) Put(key []byte, value []byte) error

Put puts bytes to the table.

func (*Tbl) PutObject

func (t *Tbl) PutObject(key []byte, obj interface{}) error

PutObject puts object to the table.

type TblBatch

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

TblBatch it's the same as batch, but with a prefix.

func (*TblBatch) CreateTableBatch

func (b *TblBatch) CreateTableBatch(prefix []byte) Batcher

CreateTableBatch creates new tablebatch instance.

func (*TblBatch) Delete

func (t *TblBatch) Delete(key []byte) error

Delete deletes value by key from the tablebatch.

func (*TblBatch) Put

func (t *TblBatch) Put(key []byte, value []byte) error

Put puts bytes to the tablebatch.

func (*TblBatch) PutObject

func (t *TblBatch) PutObject(key []byte, obj interface{}) error

PutObject puts object to the tablebatch.

func (*TblBatch) Reset

func (t *TblBatch) Reset()

Reset resets tablebatch.

func (*TblBatch) Write

func (t *TblBatch) Write() error

Write writes data from batch to the database.

type Writer

type Writer interface {
	// Put puts bytes to the database.
	Put(key, value []byte) error

	// PutObject puts object to the database.
	PutObject(key []byte, obj interface{}) error

	// Delete deletes value by key from the database.
	Delete(key []byte) error
}

Writer is a database object with write access.

Jump to

Keyboard shortcuts

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