store

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: BSD-3-Clause Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound         = badger.ErrKeyNotFound
	DefaultIteratorOptions = badger.DefaultIteratorOptions
)
View Source
var (
	ErrAlreadyExists = fmt.Errorf("already exists")
	ErrEmptyObject   = fmt.Errorf("empty object")
)

Functions

func BatchWrite

func BatchWrite(e *Entry)

BatchWrite is the helper function to set the entry backed by an internal flusher. Which makes writes faster but there is no guarantee that write has been done successfully, since we bypass the errors. TODO:: Maybe improve the flusher structure to return error in the case

func Delete added in v0.5.25

func Delete(txn *LTxn, alloc *tools.Allocator, keyParts ...interface{}) error

func Exists added in v0.5.25

func Exists(txn *LTxn, alloc *tools.Allocator, keyParts ...interface{}) bool

func Get added in v0.5.25

func Get(txn *LTxn, alloc *tools.Allocator, keyParts ...interface{}) ([]byte, error)

func GetByKey added in v0.5.25

func GetByKey(txn *LTxn, alloc *tools.Allocator, key []byte) ([]byte, error)

func Init

func Init(config Config)

func Marshal added in v0.5.25

func Marshal(txn *LTxn, alloc *tools.Allocator, m proto.Message, keyParts ...interface{}) error

func Move added in v0.5.25

func Move(txn *LTxn, oldKey, newKey []byte) error

func Set added in v0.5.25

func Set(txn *LTxn, alloc *tools.Allocator, val []byte, keyParts ...interface{}) error

func Unmarshal added in v0.5.25

func Unmarshal(txn *LTxn, alloc *tools.Allocator, m proto.Message, keyParts ...interface{}) error

func UnmarshalMerge added in v0.5.25

func UnmarshalMerge(txn *LTxn, alloc *tools.Allocator, m proto.Message, keyParts ...interface{}) error

func Update

func Update(fn func(txn *LTxn) error) (err error)

Update executes a function, creating and managing a read-write transaction for the user. Error returned by the function is relayed by the Update method. It retries in case of badger.ErrConflict returned.

func View

func View(fn func(txn *LTxn) error) (err error)

View executes a function creating and managing a read-only transaction for the user. Error returned by the function is relayed by the View method. It retries in case of badger.ErrConflict returned.

Types

type Config

type Config struct {
	DB                  *LocalDB
	ConflictRetries     int
	ConflictMaxInterval time.Duration
	BatchWorkers        int
	BatchSize           int
}

type Entry added in v0.5.6

type Entry = badger.Entry

func NewEntry added in v0.5.15

func NewEntry(key, value []byte) *Entry

type IterOption

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

func NewIterOption

func NewIterOption() *IterOption

func (*IterOption) Backward

func (o *IterOption) Backward() bool

func (*IterOption) OffsetKey

func (o *IterOption) OffsetKey() []byte

func (*IterOption) OnClose

func (o *IterOption) OnClose(key []byte)

func (*IterOption) SetBackward

func (o *IterOption) SetBackward() *IterOption

func (*IterOption) SetForward

func (o *IterOption) SetForward() *IterOption

func (*IterOption) SetOffsetKey

func (o *IterOption) SetOffsetKey(offset []byte) *IterOption

func (*IterOption) SetOnClose

func (o *IterOption) SetOnClose(f func(key []byte)) *IterOption

type LTxn added in v0.7.2

type LTxn = badger.Txn

type ListOption

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

func NewListOption

func NewListOption() *ListOption

func (*ListOption) Backward

func (o *ListOption) Backward() bool

func (*ListOption) Limit

func (o *ListOption) Limit() int32

func (*ListOption) SetBackward

func (o *ListOption) SetBackward() *ListOption

func (*ListOption) SetForward

func (o *ListOption) SetForward() *ListOption

func (*ListOption) SetLimit

func (o *ListOption) SetLimit(limit int32) *ListOption

func (*ListOption) SetSkip

func (o *ListOption) SetSkip(skip int32) *ListOption

func (*ListOption) Skip

func (o *ListOption) Skip() int32

type LocalDB added in v0.7.2

type LocalDB = badger.DB

func DB

func DB() *LocalDB

DB returns the underlying object of the database

type Store added in v0.5.6

type Store interface {
	View(fn func(Txn) error) error
	Update(fn func(Txn) error) error
	ViewLocal(fn func(txn *LTxn) error) error
	UpdateLocal(fn func(txn *LTxn) error) error
	DB() *LocalDB
	Shutdown()
}

type Txn added in v0.5.6

type Txn interface {
	Delete(alloc *tools.Allocator, keyParts ...interface{}) error
	Set(alloc *tools.Allocator, val []byte, keyParts ...interface{}) error
	Get(alloc *tools.Allocator, keyParts ...interface{}) ([]byte, error)
	Exists(alloc *tools.Allocator, keyParts ...interface{}) bool
}

Jump to

Keyboard shortcuts

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