kv

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2021 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = Config{
		DirPath:             "./_hdd",
		ConflictRetries:     100,
		ConflictMaxInterval: time.Millisecond,
		BatchSize:           defaultBatchSize,
		BatchWorkers:        defaultBatchWorkers,
	}
)

Functions

func BatchWrite added in v0.3.2

func BatchWrite(e *badger.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 DB

func DB() *badger.DB

DB returns the underlying object of the database

func Index added in v0.2.7

func Index() *buntdb.DB

Index returns the underlying object of the index db

func Init

func Init(config Config) error

func MustInit

func MustInit(config Config)

func Update

func Update(fn func(txn *badger.Txn) 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 UpdateIndex added in v0.2.7

func UpdateIndex(fn func(tx *buntdb.Tx) error) (err error)

UpdateIndex executes a function within a managed read/write transaction. The transaction has been committed when no error is returned. In the event that an error is returned, the transaction will be rolled back. When a non-nil error is returned from the function, the transaction will be rolled back and the that error will be return to the caller of UpdateIndex().

Executing a manual commit or rollback from inside the function will result in a panic.

func View

func View(fn func(txn *badger.Txn) 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.

func ViewIndex added in v0.2.7

func ViewIndex(fn func(tx *buntdb.Tx) error) error

ViewIndex executes a function within a managed read-only transaction. When a non-nil error is returned from the function that error will be return to the caller of ViewIndex().

Executing a manual commit or rollback from inside the function will result in a panic.

Types

type Allocator added in v0.2.6

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

func NewAllocator added in v0.2.6

func NewAllocator() *Allocator

func (*Allocator) GenKey added in v0.2.6

func (bk *Allocator) GenKey(v ...interface{}) []byte

func (*Allocator) GenValue added in v0.2.6

func (bk *Allocator) GenValue(m proto.Message) []byte

func (*Allocator) ReleaseAll added in v0.2.6

func (bk *Allocator) ReleaseAll()

type Config

type Config struct {
	DirPath             string
	ConflictRetries     int
	ConflictMaxInterval time.Duration
	BatchWorkers        int
	BatchSize           int
}

type ListOption added in v0.3.10

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

func NewListOption added in v0.3.10

func NewListOption() *ListOption

func (*ListOption) Backward added in v0.3.10

func (o *ListOption) Backward() bool

func (*ListOption) Limit added in v0.3.10

func (o *ListOption) Limit() int32

func (*ListOption) SetBackward added in v0.3.10

func (o *ListOption) SetBackward() *ListOption

func (*ListOption) SetForward added in v0.3.10

func (o *ListOption) SetForward() *ListOption

func (*ListOption) SetLimit added in v0.3.10

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

func (*ListOption) SetSkip added in v0.3.10

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

func (*ListOption) Skip added in v0.3.10

func (o *ListOption) Skip() int32

Jump to

Keyboard shortcuts

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