boltdb

package
v0.0.0-...-eb4623f Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("Not Found")
	ErrEOF      = errors.New("End of file")
)

Functions

This section is empty.

Types

type Batch

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

func (*Batch) Delete

func (b *Batch) Delete(key []byte, opts *ethdb.Option) error

Delete removes the key from the key-value data store.

func (*Batch) Put

func (b *Batch) Put(key []byte, value []byte, opts *ethdb.Option) error

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

func (*Batch) Replay

func (b *Batch) Replay(w ethdb.KeyValueWriter, opts *ethdb.Option) error

Replay replays the batch contents.

func (*Batch) Reset

func (b *Batch) Reset()

Reset resets the batch for reuse.

func (*Batch) ValueSize

func (b *Batch) ValueSize() int

ValueSize retrieves the amount of data queued up for writing.

func (*Batch) Write

func (b *Batch) Write() error

Write flushes any accumulated data to disk.

type BoltDB

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

func NewBoltDB

func NewBoltDB(path string) (*BoltDB, error)

func (*BoltDB) Close

func (d *BoltDB) Close() error

func (*BoltDB) Compact

func (d *BoltDB) Compact(start []byte, limit []byte, opts *ethdb.Option) 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 (*BoltDB) Delete

func (d *BoltDB) Delete(key []byte, opts *ethdb.Option) error

Delete removes the key from the key-value data store.

func (*BoltDB) Get

func (d *BoltDB) Get(key []byte, opts *ethdb.Option) ([]byte, error)

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

func (*BoltDB) Has

func (d *BoltDB) Has(key []byte, opts *ethdb.Option) (bool, error)

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

func (*BoltDB) NewBatch

func (d *BoltDB) NewBatch() ethdb.Batch

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

func (*BoltDB) NewIterator

func (d *BoltDB) NewIterator(prefix []byte, start []byte, opts *ethdb.Option) ethdb.Iterator

NewIterator creates a binary-alphabetical iterator over a subset of database content with a particular key prefix, starting at a particular initial key (or after, if it does not exist).

Note: This method assumes that the prefix is NOT part of the start, so there's no need for the caller to prepend the prefix to the start

func (*BoltDB) Path

func (d *BoltDB) Path() string

func (*BoltDB) Put

func (d *BoltDB) Put(key []byte, value []byte, opts *ethdb.Option) error

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

func (*BoltDB) Stat

func (d *BoltDB) Stat(property string, opts *ethdb.Option) (string, error)

Stat returns a particular internal stat of the database.

type Iter

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

func (*Iter) Error

func (i *Iter) Error() error

Error returns any accumulated error. Exhausting all the key/value pairs is not considered to be an error.

func (*Iter) Key

func (i *Iter) Key() []byte

Key returns the key of the current key/value pair, or nil if done. The caller should not modify the contents of the returned slice, and its contents may change on the next call to Next.

func (*Iter) Next

func (i *Iter) Next() bool

Next moves the iterator to the next key/value pair. It returns whether the iterator is exhausted.

func (*Iter) Release

func (i *Iter) Release()

Release releases associated resources. Release should always succeed and can be called multiple times without causing error.

func (*Iter) Value

func (i *Iter) Value() []byte

Value returns the value of the current key/value pair, or nil if done. The caller should not modify the contents of the returned slice, and its contents may change on the next call to Next.

Jump to

Keyboard shortcuts

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