db

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 8 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) Purge

func (s *BadgerStore) Purge() error

Purge purges any old/deleted keys from the database.

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 BadgerStoreTxn

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

func (*BadgerStoreTxn) Commit

func (t *BadgerStoreTxn) Commit(callback func(error)) 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) 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) 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
}

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 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
	Commit(callback func(error)) error
	Discard()
	Drop(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