Documentation
¶
Index ¶
- Variables
- func DecodeUint64(valueBytes []byte) uint64
- func EncodeUint64(value uint64) []byte
- type Bucket
- func (bucket *Bucket) Bucket(path []byte) (*Bucket, error)
- func (bucket *Bucket) DB() *DB
- func (bucket *Bucket) Delete(key []byte) error
- func (bucket *Bucket) DeleteBucket(path []byte) error
- func (bucket *Bucket) Get(key []byte) []byte
- func (bucket *Bucket) Iterate() *Iterator
- func (bucket *Bucket) Name() []byte
- func (bucket *Bucket) NextSequence() (uint64, error)
- func (bucket *Bucket) Put(key []byte, value []byte) error
- func (bucket *Bucket) Stats() BucketStats
- func (bucket *Bucket) TX() *TX
- func (bucket *Bucket) WithIterator(opts IteratorOptions, cb WithinIteratorCallback) error
- type BucketStats
- type DB
- func (db *DB) BeginTx(opts TxOptions) (*TX, error)
- func (db *DB) Close()
- func (db *DB) Delete(bucket []byte, key []byte) error
- func (db *DB) Get(bucket []byte, key []byte) ([]byte, error)
- func (db *DB) Put(bucket []byte, key []byte, value []byte) error
- func (db *DB) WithinTx(opts TxOptions, cb WithinTxCallback) error
- type Iterator
- func (iter *Iterator) Bucket() *Bucket
- func (iter *Iterator) CopyValue() []byte
- func (iter *Iterator) Delete() error
- func (iter *Iterator) First() bool
- func (iter *Iterator) HasKeyPrefix(prefix []byte) bool
- func (iter *Iterator) IsNestedBucket() bool
- func (iter *Iterator) IsValid() bool
- func (iter *Iterator) Key() []byte
- func (iter *Iterator) Last() bool
- func (iter *Iterator) Next() bool
- func (iter *Iterator) Prev() bool
- func (iter *Iterator) Seek(prefix []byte, method SeekMethod) bool
- func (iter *Iterator) Value() []byte
- type IteratorOptions
- type Options
- type SeekMethod
- type TX
- type TxOptions
- type WithinIteratorCallback
- type WithinTxCallback
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidPath = errors.New("invalid path") ErrBucketNotFound = bbolt.ErrBucketNotFound ErrTxNotWritable = bbolt.ErrTxNotWritable ErrDatabaseReadOnly = bbolt.ErrDatabaseReadOnly ErrInvalidCursorPosition = errors.New("invalid cursor position") )
Functions ¶
func DecodeUint64 ¶
DecodeUint64 decodes a little endian uint64 value
func EncodeUint64 ¶
EncodeUint64 stores an uint64 into a byte array using little endian format
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket represents a directory that contains keys and values inside the database.
func (*Bucket) DeleteBucket ¶
DeleteBucket removes an existing child bucket on the database NOTE: Inner sub-keys and buckets will be also deleted
func (*Bucket) NextSequence ¶
NextSequence returns an autoincrement integer for the bucket.
func (*Bucket) Stats ¶
func (bucket *Bucket) Stats() BucketStats
func (*Bucket) WithIterator ¶
func (bucket *Bucket) WithIterator(opts IteratorOptions, cb WithinIteratorCallback) error
type BucketStats ¶
type BucketStats = bbolt.BucketStats
BucketStats contains statistical data about a bucket.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a database connection to a BoltDB database.
func NewWithOptions ¶
NewWithOptions returns a new database wrapper using the provided options.
func (*DB) Delete ¶
Delete deletes a specific key in the specified bucket. No error is returned if key is not found.
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator encapsulates a bucket key/value iterator
func (*Iterator) CopyValue ¶
CopyValue acts like Value but returns a copy of the value so it remains valid after moving the iterator position.
func (*Iterator) HasKeyPrefix ¶
HasKeyPrefix checks if the current key has the provided prefix.
func (*Iterator) IsNestedBucket ¶
IsNestedBucket returns true if the iterator is pointing to a nested bucket.
func (*Iterator) IsValid ¶
IsValid returns true if the iterator is pointing to some value or nested bucket.
func (*Iterator) Key ¶
Key gets the current iterator key. Nil if reached the end or a search failed. The key is valid until the iterator position is changed.
type IteratorOptions ¶
type IteratorOptions struct {
// Reverse scan keys in reverse order.
Reverse bool
// Prefix filters the iterator to keys with the given prefix. It cannot be used in conjunction with FirstKey.
Prefix []byte
// FirstKey sets the start point of the iterator. It cannot be used with Prefix.
FirstKey []byte
}
type SeekMethod ¶
type SeekMethod int
const ( SeekExact SeekMethod = iota SeekPrefix SeekMethod = iota SeekPrefixReverse SeekMethod = iota SeekGreaterOrEqual SeekMethod = iota SeekLessOrEqual SeekMethod = iota )
type TX ¶
type TX struct {
// contains filtered or unexported fields
}
TX represents a transaction within the database.
func (*TX) Bucket ¶
Bucket returns a bucket on the database. If the transaction is writable and the bucket does not exist, this function will try to create it.
func (*TX) Commit ¶
Commit stores the transaction changes into the database and, on success, ends the operation.
func (*TX) DeleteBucket ¶
DeleteBucket removes an existing child bucket from the database including nested buckets and stored keys.
type TxOptions ¶
type TxOptions struct {
ReadOnly bool
}
TxOptions specifies a set of options when starting a transaction.
type WithinIteratorCallback ¶
WithinIteratorCallback is a callback that is called for every key found in the given request NOTE: If value == nil, then they key points to a child bucket
type WithinTxCallback ¶
WithinTxCallback is a callback to be called after the transaction is initiated.