Documentation
¶
Index ¶
- Variables
- type BadgerDB
- func (db *BadgerDB) ClearAll() error
- func (db *BadgerDB) Close() error
- func (db *BadgerDB) Del(key []byte) error
- func (db *BadgerDB) Flush() error
- func (db *BadgerDB) Get(key []byte) (data []byte, err error)
- func (db *BadgerDB) Has(key []byte) (exists bool, err error)
- func (db *BadgerDB) NewBatch() Batch
- func (db *BadgerDB) NewIterator() Iterator
- func (db *BadgerDB) Path() string
- func (db *BadgerDB) Put(key []byte, value []byte) error
- func (db *BadgerDB) Subscribe(ctx context.Context, cb func(kv *KVList) error, prefixes []pb.Match) error
- type BadgerIterator
- type Batch
- type Config
- type Database
- type Iterator
- type KVList
- type Reader
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrKeyNotFound = badger.ErrKeyNotFound
ErrKeyNotFound is returned if there is a database get for a key that does not exist
Functions ¶
This section is empty.
Types ¶
type BadgerDB ¶
type BadgerDB struct {
// contains filtered or unexported fields
}
BadgerDB contains directory path to data and db instance
func NewBadgerDB ¶
NewBadgerDB initializes badgerDB instance
func (*BadgerDB) NewBatch ¶
NewBatch returns batchWriter with a badgerDB instance and an initialized mapping
func (*BadgerDB) NewIterator ¶
NewIterator returns a new iterator within the Iterator struct along with a new transaction
type BadgerIterator ¶ added in v0.1.0
type BadgerIterator struct {
// contains filtered or unexported fields
}
BadgerIterator struct contains a transaction, iterator and init.
func (*BadgerIterator) Key ¶ added in v0.1.0
func (i *BadgerIterator) Key() []byte
Key returns an item key
func (*BadgerIterator) Next ¶ added in v0.1.0
func (i *BadgerIterator) Next() bool
Next rewinds the iterator to the zero-th position if uninitialized, and then will advance the iterator by one returns bool to ensure access to the item
func (*BadgerIterator) Release ¶ added in v0.1.0
func (i *BadgerIterator) Release()
Release closes the iterator and discards the created transaction.
func (*BadgerIterator) Seek ¶ added in v0.1.0
func (i *BadgerIterator) Seek(key []byte)
Seek will look for the provided key if present and go to that position. If absent, it would seek to the next smallest key
func (*BadgerIterator) Valid ¶ added in v0.1.5
func (i *BadgerIterator) Valid() bool
Valid returns whether the current iterator position has an item.
func (*BadgerIterator) Value ¶ added in v0.1.0
func (i *BadgerIterator) Value() []byte
Value returns a copy of the value of the item
type Batch ¶
Batch is a write-only operation.
func NewTableBatch ¶
NewTableBatch returns a Batch object which prefixes all keys with a given string.
type Database ¶
type Database interface { Reader Writer io.Closer NewBatch() Batch Path() string NewIterator() Iterator Subscribe(ctx context.Context, cb func(kv *KVList) error, prefixes []pb.Match) error ClearAll() error }
Database wraps all database operations. All methods are safe for concurrent use.
type Iterator ¶
Iterator iterates over key/value pairs in ascending key order. Must be released after use.