Documentation
¶
Index ¶
- type BadgerDB
- func (bdb *BadgerDB) Close() error
- func (bdb *BadgerDB) Delete(key []byte) error
- func (bdb *BadgerDB) Get(key []byte) (value []byte, err error)
- func (bdb *BadgerDB) Has(key []byte) bool
- func (bdb *BadgerDB) IteratePrefix(prefix []byte, cb func(k, v []byte) bool)
- func (bdb *BadgerDB) Set(key, value []byte) error
- type DB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerDB ¶
type BadgerDB struct {
// contains filtered or unexported fields
}
BadgerDB defines a wrapper type around a Badger DB that implements the DB interface. It mainly provides transaction abstractions.
func (*BadgerDB) Delete ¶
Delete attempts to remove a value by key from Badger DB returning an error upon failure.
func (*BadgerDB) Get ¶
Get returns a value for a given key. It returns badger.ErrKeyNotFound if the value is not found.
func (*BadgerDB) Has ¶
Has returns a boolean determining if the underlying Badger DB has a given key or not.
func (*BadgerDB) IteratePrefix ¶
IteratePrefix iterates over a series of key/value pairs where each key contains the provided prefix. For each key/value pair, a cb function is invoked. If cb returns true, iteration is halted.
type DB ¶
type DB interface {
Get(key []byte) ([]byte, error)
Has(key []byte) bool
Set(key, value []byte) error
Delete(key []byte) error
IteratePrefix(prefix []byte, cb func(k, v []byte) bool)
Close() error
}
DB defines the persistence interface for tmcrawl.
func NewBadgerDB ¶
NewBadgerDB returns a wrapper around a Badger DB that implements the DB interface. It will create all the necessary Badger DB buckets if they don't already exist.
func NewBadgerMemDB ¶
NewBadgerMemDB return a pure in-memory Badger DB instance that implements the DB interface. Data is stored only in-memory and should be used for testing purposes only.