utils

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 6 Imported by: 1

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
}

func MustNewBucket

func MustNewBucket(tx *badger.Txn, prefix Key) Bucket

func NewBucket

func NewBucket(tx *badger.Txn, prefix Key) (Bucket, error)

func (Bucket) ChildBucket

func (b Bucket) ChildBucket(component KeyComponent) Bucket

func (Bucket) Delete

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

func (Bucket) DeleteBucket

func (b Bucket) DeleteBucket() error

func (Bucket) ForEach

func (b Bucket) ForEach(fn func(item Item) error) error

func (Bucket) Get

func (b Bucket) Get(key []byte) (Item, error)

func (Bucket) IsEmpty

func (b Bucket) IsEmpty() bool

func (Bucket) Iterator

func (b Bucket) Iterator() *BucketIterator

func (Bucket) IteratorWithModifiedOptions

func (b Bucket) IteratorWithModifiedOptions(fn func(options *badger.IteratorOptions)) *BucketIterator

func (Bucket) KeyInBucket

func (b Bucket) KeyInBucket(item Item) (KeyComponent, error)

func (Bucket) Prefix

func (b Bucket) Prefix() Key

func (Bucket) Set

func (b Bucket) Set(key, val []byte) error

type BucketIterator

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

func NewBucketIterator

func NewBucketIterator(bucket Bucket) *BucketIterator

func NewBucketIteratorWithModifiedOptions

func NewBucketIteratorWithModifiedOptions(bucket Bucket, fn func(options *badger.IteratorOptions)) *BucketIterator

func (BucketIterator) Close

func (i BucketIterator) Close()

func (BucketIterator) Item

func (i BucketIterator) Item() Item

func (BucketIterator) Next

func (i BucketIterator) Next()

func (BucketIterator) Rewind

func (i BucketIterator) Rewind()

func (BucketIterator) Seek

func (i BucketIterator) Seek(key []byte)

func (BucketIterator) Valid

func (i BucketIterator) Valid() bool

func (BucketIterator) ValidForBucket

func (i BucketIterator) ValidForBucket() bool

type Counter

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

func NewCounter

func NewCounter(bucket Bucket, key KeyComponent) (Counter, error)

func (Counter) Decrement

func (c Counter) Decrement() error

func (Counter) Get

func (c Counter) Get() (uint64, error)

func (Counter) Increment

func (c Counter) Increment() error

type Item

type Item interface {
	KeyCopy([]byte) []byte
	ValueCopy([]byte) ([]byte, error)

	DangerousKey(func(key []byte) error) error
	DangerousValue(func(value []byte) error) error
}

type Key

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

func MustNewKey

func MustNewKey(components ...KeyComponent) Key

func NewKey

func NewKey(components ...KeyComponent) (Key, error)

func NewKeyFromBytes

func NewKeyFromBytes(b []byte) (Key, error)

func NewKeyFromBytesReusingComponents

func NewKeyFromBytesReusingComponents(b []byte, components []KeyComponent) (Key, error)

func (Key) Append

func (k Key) Append(component KeyComponent) Key

func (Key) Bytes

func (k Key) Bytes() []byte

func (Key) Components

func (k Key) Components() []KeyComponent

func (Key) IsZero

func (k Key) IsZero() bool

func (Key) Len

func (k Key) Len() int

type KeyComponent

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

func MustNewKeyComponent

func MustNewKeyComponent(b []byte) KeyComponent

func NewKeyComponent

func NewKeyComponent(b []byte) (KeyComponent, error)

func (KeyComponent) Bytes

func (k KeyComponent) Bytes() []byte

func (KeyComponent) IsZero

func (k KeyComponent) IsZero() bool

type Sequence

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

func NewSequence

func NewSequence(bucket Bucket, key KeyComponent) (Sequence, error)

func (Sequence) Get

func (s Sequence) Get() (uint64, error)

func (Sequence) Next

func (s Sequence) Next() (uint64, error)

Next returns the next sequence and saves it. First call to next returns 1.

func (Sequence) Set

func (s Sequence) Set(v uint64) error

Jump to

Keyboard shortcuts

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