badgerdb

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket is an internal type used to represent a collection of key/value pairs and implements the walletdb Bucket interfaces.

func (*Bucket) CreateBucket

func (b *Bucket) CreateBucket(key []byte) (walletdb.ReadWriteBucket, error)

CreateBucket creates and returns a new nested bucket with the given key. Errors with code Exist if the bucket already exists, and Invalid if the key is empty or otherwise invalid for the driver.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) CreateBucketIfNotExists

func (b *Bucket) CreateBucketIfNotExists(key []byte) (walletdb.ReadWriteBucket, error)

CreateBucketIfNotExists creates and returns a new nested bucket with the given key if it does not already exist. Errors with code Invalid if the key is empty or otherwise invalid for the driver.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) Delete

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

Delete removes the specified key from the bucket. Deleting a key that does not exist does not return an error.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) DeleteNestedBucket

func (b *Bucket) DeleteNestedBucket(key []byte) error

DeleteNestedBucket removes a nested bucket with the given key.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) ForEach

func (b *Bucket) ForEach(fn func(k, v []byte) error) error

ForEach invokes the passed function with every key/value pair in the bucket. This includes nested buckets, in which case the value is nil, but it does not include the key/value pairs within those nested buckets.

NOTE: The values returned by this function are only valid during a transaction. Attempting to access them after a transaction has ended will likely result in an access violation.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) Get

func (b *Bucket) Get(key []byte) []byte

Get returns the value for the given key. Returns nil if the key does not exist in this bucket (or nested buckets).

NOTE: The value returned by this function is only valid during a transaction. Attempting to access it after a transaction has ended will likely result in an access violation.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) KeyN

func (b *Bucket) KeyN() int

KeyN returns the number of keys and value pairs inside a bucket.

This function is part of the walletdb.ReadBucket interface implementation.

func (*Bucket) NestedReadBucket

func (b *Bucket) NestedReadBucket(key []byte) walletdb.ReadBucket

func (*Bucket) NestedReadWriteBucket

func (b *Bucket) NestedReadWriteBucket(key []byte) walletdb.ReadWriteBucket

NestedReadWriteBucket retrieves a nested bucket with the given key. Returns nil if the bucket does not exist.

This function is part of the walletdb.ReadWriteBucket interface implementation.

func (*Bucket) Put

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

Put saves the specified key/value pair to the bucket. Keys that do not already exist are added and keys that already exist are overwritten.

This function is part of the walletdb.Bucket interface implementation.

func (*Bucket) ReadCursor

func (b *Bucket) ReadCursor() walletdb.ReadCursor

func (*Bucket) ReadWriteCursor

func (b *Bucket) ReadWriteCursor() walletdb.ReadWriteCursor

ReadWriteCursor returns a new cursor, allowing for iteration over the bucket's key/value pairs and nested buckets in forward or backward order.

This function is part of the walletdb.Bucket interface implementation.

type Cursor

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

Cursor represents a cursor over key/value pairs and nested buckets of a bucket.

Note that open cursors are not tracked on bucket changes and any modifications to the bucket, with the exception of cursor.Delete, invalidate the cursor. After invalidation, the cursor must be repositioned, or the keys and values returned may be unpredictable.

func (*Cursor) Close

func (c *Cursor) Close()

Close the cursor

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) Delete

func (c *Cursor) Delete() error

Delete removes the current key/value pair the cursor is at without invalidating the cursor.

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) First

func (c *Cursor) First() (key, value []byte)

First positions the cursor at the first key/value pair and returns the pair.

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) Last

func (c *Cursor) Last() (key, value []byte)

Last positions the cursor at the last key/value pair and returns the pair.

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) Next

func (c *Cursor) Next() (key, value []byte)

Next moves the cursor one key/value pair forward and returns the new pair.

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) Prev

func (c *Cursor) Prev() (key, value []byte)

Prev moves the cursor one key/value pair backward and returns the new pair.

This function is part of the walletdb.Cursor interface implementation.

func (*Cursor) Seek

func (c *Cursor) Seek(seek []byte) (key, value []byte)

Seek positions the cursor at the passed seek key. If the key does not exist, the cursor is moved to the next key after seek. Returns the new pair.

This function is part of the walletdb.Cursor interface implementation.

Jump to

Keyboard shortcuts

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