db

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerStore

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

BadgerStore represents a block lattice store backed by a badger database.

func (*BadgerStore) Close

func (s *BadgerStore) Close() error

Close closes the database

func (*BadgerStore) Erase

func (s *BadgerStore) Erase() error

func (*BadgerStore) NewTransaction

func (s *BadgerStore) NewTransaction(update bool) *BadgerStoreTxn

func (*BadgerStore) NewWriteBatch added in v1.3.0

func (s *BadgerStore) NewWriteBatch() *BadgerStoreBatch

func (*BadgerStore) Purge

func (s *BadgerStore) Purge() error

Purge purges any old/deleted keys from the database.

func (*BadgerStore) Size added in v1.3.0

func (s *BadgerStore) Size() (int64, int64)

Close closes the database

func (*BadgerStore) UpdateInBatch added in v1.3.0

func (s *BadgerStore) UpdateInBatch(fn func(batch StoreBatch) error) error

func (*BadgerStore) UpdateInTx

func (s *BadgerStore) UpdateInTx(fn func(txn StoreTxn) error) error

func (*BadgerStore) ViewInTx

func (s *BadgerStore) ViewInTx(fn func(txn StoreTxn) error) error

type BadgerStoreBatch added in v1.3.0

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

func (*BadgerStoreBatch) Cancel added in v1.3.0

func (b *BadgerStoreBatch) Cancel()

func (*BadgerStoreBatch) Delete added in v1.3.0

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

func (*BadgerStoreBatch) Flush added in v1.3.0

func (b *BadgerStoreBatch) Flush() error

func (*BadgerStoreBatch) Set added in v1.3.0

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

func (*BadgerStoreBatch) SetWithMeta added in v1.3.0

func (b *BadgerStoreBatch) SetWithMeta(key, val []byte, meta byte) error

type BadgerStoreTxn

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

func (*BadgerStoreTxn) Commit

func (t *BadgerStoreTxn) Commit() error

func (*BadgerStoreTxn) Count added in v0.0.9

func (t *BadgerStoreTxn) Count(prefix []byte) (uint64, error)

func (*BadgerStoreTxn) Delete

func (t *BadgerStoreTxn) Delete(key []byte) error

func (*BadgerStoreTxn) Discard

func (t *BadgerStoreTxn) Discard()

func (*BadgerStoreTxn) Drop added in v1.0.4

func (t *BadgerStoreTxn) Drop(prefix []byte) error

func (*BadgerStoreTxn) DropOfTxn added in v1.3.2

func (t *BadgerStoreTxn) DropOfTxn(prefix []byte) error

func (*BadgerStoreTxn) Get

func (t *BadgerStoreTxn) Get(key []byte, fn func([]byte, byte) error) error

func (*BadgerStoreTxn) Iterator

func (t *BadgerStoreTxn) Iterator(pre byte, fn func([]byte, []byte, byte) error) error

func (*BadgerStoreTxn) PrefixIterator added in v1.2.3

func (t *BadgerStoreTxn) PrefixIterator(prefix []byte, fn func([]byte, []byte, byte) error) error

func (*BadgerStoreTxn) RangeIterator added in v1.2.3

func (t *BadgerStoreTxn) RangeIterator(startKey []byte, endKey []byte, fn func([]byte, []byte, byte) error) error

RangeIterator scan keys between [startKey, endKey)

func (*BadgerStoreTxn) Set

func (t *BadgerStoreTxn) Set(key []byte, val []byte) error

func (*BadgerStoreTxn) SetWithMeta

func (t *BadgerStoreTxn) SetWithMeta(key, val []byte, meta byte) error

func (*BadgerStoreTxn) Stream added in v0.0.9

func (t *BadgerStoreTxn) Stream(prefix []byte, filter func(item *badger.Item) bool, callback func(list *pb.KVList) error) error

func (*BadgerStoreTxn) Upgrade

func (t *BadgerStoreTxn) Upgrade(migrations []Migration) error

type Migration

type Migration interface {
	Migrate(txn StoreTxn) error
	StartVersion() int
	EndVersion() int
}

type Migrations

type Migrations []Migration

func (Migrations) Len

func (m Migrations) Len() int

func (Migrations) Less

func (m Migrations) Less(i, j int) bool

func (Migrations) Swap

func (m Migrations) Swap(i, j int)

type Store

type Store interface {
	io.Closer
	Purge() error
	Erase() error
	ViewInTx(fn func(txn StoreTxn) error) error
	UpdateInTx(fn func(txn StoreTxn) error) error
	NewTransaction(update bool) *BadgerStoreTxn
	NewWriteBatch() *BadgerStoreBatch
	UpdateInBatch(fn func(batch StoreBatch) error) error
	Size() (int64, int64)
}

Store is an interface that all stores need to implement.

func NewBadgerStore

func NewBadgerStore(dir string) (Store, error)

NewBadgerStore initializes/opens a badger database in the given directory.

type StoreBatch added in v1.3.0

type StoreBatch interface {
	Set(key, val []byte) error
	SetWithMeta(key, val []byte, meta byte) error
	Delete(key []byte) error
	Cancel()
	Flush() error
}

type StoreTxn

type StoreTxn interface {
	Set(key, val []byte) error
	SetWithMeta(key, val []byte, meta byte) error
	Get(key []byte, fn func([]byte, byte) error) error
	Delete(key []byte) error
	Iterator(pre byte, fn func([]byte, []byte, byte) error) error
	PrefixIterator(prefix []byte, fn func([]byte, []byte, byte) error) error
	RangeIterator(startKey []byte, endKey []byte, fn func([]byte, []byte, byte) error) error
	Commit() error
	Discard()
	Drop(prefix []byte) error
	DropOfTxn(prefix []byte) error
	Upgrade(migrations []Migration) error
	Count(prefix []byte) (uint64, error)
	Stream(prefix []byte, filter func(item *badger.Item) bool, callback func(list *pb.KVList) error) error
}

Jump to

Keyboard shortcuts

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