boltdd

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

BOLTdd contains a wrapper around BoltDB to deduplicate writes and encode values using mgspack. (dd stands for DeDuplicate)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrNotFound

func IsErrNotFound(e error) bool

IsErrNotFound returns true if the error is an ErrNotFound error.

func NotFound

func NotFound(name string) error

NotFound returns a new error for a key that was not found.

Types

type Bucket

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

func (*Bucket) BoltBucket

func (b *Bucket) BoltBucket() *bolt.Bucket

BoltBucket returns the internal bolt.Bucket for this Bucket. Only valid for the duration of the current transaction.

func (*Bucket) Bucket

func (b *Bucket) Bucket(name []byte) *Bucket

Bucket represents a boltdb Bucket and its associated metadata necessary for write deduplication. Like bolt.Buckets it is only valid for the duration of the transaction that created it.

func (*Bucket) CreateBucket

func (b *Bucket) CreateBucket(name []byte) (*Bucket, error)

CreateBucket creates a new bucket at the given key and returns the new bucket. Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long. The bucket instance is only valid for the lifetime of the transaction.

func (*Bucket) CreateBucketIfNotExists

func (b *Bucket) CreateBucketIfNotExists(name []byte) (*Bucket, error)

CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. The bucket instance is only valid for the lifetime of the transaction.

func (*Bucket) Delete

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

Delete removes a key from the bucket. If the key does not exist then nothing is done and a nil error is returned. Returns an error if the bucket was created from a read-only transaction.

func (*Bucket) DeleteBucket

func (b *Bucket) DeleteBucket(name []byte) error

DeleteBucket deletes a child bucket. Returns an error if the bucket corresponds to a non-bucket key or another error is encountered. No error is returned if the bucket does not exist.

func (*Bucket) Get

func (b *Bucket) Get(key []byte, obj interface{}) error

Get value by key from boltdb or return an ErrNotFound error if key not found.

func (*Bucket) Put

func (b *Bucket) Put(key []byte, val interface{}) error

Put into boltdb iff it has changed since the last write.

type DB

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

DB wraps an underlying bolt.DB to create write deduplicating buckets and msgpack encoded values.

func New

func New(bdb *bolt.DB) *DB

New deduplicating wrapper for the given boltdb.

func Open

func Open(path string, mode os.FileMode, options *bolt.Options) (*DB, error)

Open a bolt.DB and wrap it in a write-deduplicating msgpack-encoding implementation.

func (*DB) BoltDB

func (db *DB) BoltDB() *bolt.DB

BoltDB returns the underlying bolt.DB.

func (*DB) Close

func (db *DB) Close() error

Close closes the underlying bolt.DB and clears all bucket hashes. DB is unusable after closing.

func (*DB) Update

func (db *DB) Update(fn func(*Tx) error) error

func (*DB) View

func (db *DB) View(fn func(*Tx) error) error

type ErrNotFound

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

ErrNotFound is returned when a key is not found.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

type Tx

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

func (*Tx) BoltTx

func (tx *Tx) BoltTx() *bolt.Tx

BoltTx returns the underlying bolt.Tx.

func (*Tx) Bucket

func (tx *Tx) Bucket(name []byte) *Bucket

Bucket returns a root bucket or nil if it doesn't exist.

func (*Tx) CreateBucket

func (tx *Tx) CreateBucket(name []byte) (*Bucket, error)

func (*Tx) CreateBucketIfNotExists

func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error)

CreateBucketIfNotExists returns a root bucket or creates a new one if it doesn't already exist.

func (*Tx) Writable

func (tx *Tx) Writable() bool

Writable wraps boltdb Tx.Writable.

Jump to

Keyboard shortcuts

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