Documentation
¶
Index ¶
- Variables
- type BadgerDB
- func (db *BadgerDB) Close() error
- func (db *BadgerDB) Del(key []byte) 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() Iterable
- func (db *BadgerDB) Path() string
- func (db *BadgerDB) Put(key []byte, value []byte) error
- type Batch
- type Config
- type Database
- type Iterable
- type Iteratee
- type Iterator
- type MemDatabase
- func (db *MemDatabase) Close() error
- func (db *MemDatabase) Del(key []byte) error
- func (db *MemDatabase) Get(k []byte) ([]byte, error)
- func (db *MemDatabase) Has(k []byte) (bool, error)
- func (db *MemDatabase) Keys() [][]byte
- func (db *MemDatabase) NewBatch() Batch
- func (db *MemDatabase) NewIterator() Iterable
- func (db *MemDatabase) Path() string
- func (db *MemDatabase) Put(k []byte, v []byte) error
- type PutItem
- 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 Batch ¶
Batch is a write-only operation
func NewTableBatch ¶
NewTableBatch returns a Batch object which prefixes all keys with a given string.
type Config ¶
type Config struct {
DataDir string
}
Config defines configurations for BadgerService instance
type Database ¶
type Database interface {
PutItem
Iteratee
Get(key []byte) ([]byte, error)
Has(key []byte) (bool, error)
Del(key []byte) error
NewBatch() Batch
Close() error
Path() string
}
Database wraps all database operations. All methods are safe for concurrent use.
type Iterable ¶
type Iterable struct {
// contains filtered or unexported fields
}
Iterable struct contains a transaction, iterator and context fields released, initialized
func (*Iterable) Next ¶
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 (*Iterable) Release ¶
func (i *Iterable) Release()
Release closes the iterator, discards the created transaction and sets released value to true
func (*Iterable) Released ¶
Released returns the boolean indicating whether the iterator and transaction was successfully released
type Iteratee ¶
type Iteratee interface {
NewIterator() Iterable
}
Iteratee wraps the NewIterator methods of BadgerService
type Iterator ¶
Iterator iterates over BadgerDBs key/value pairs in ascending key order must be released after use
type MemDatabase ¶
type MemDatabase struct {
// contains filtered or unexported fields
}
MemDatabase test memory database, data is not persisted
func NewMemDatabase ¶
func NewMemDatabase() *MemDatabase
NewMemDatabase returns an initialized mapping used for test database
func (*MemDatabase) Del ¶
func (db *MemDatabase) Del(key []byte) error
Del removes the key from the mapping
func (*MemDatabase) Get ¶
func (db *MemDatabase) Get(k []byte) ([]byte, error)
Get returns the given key []byte
func (*MemDatabase) Has ¶
func (db *MemDatabase) Has(k []byte) (bool, error)
Has checks the given key exists already; returning true or false
func (*MemDatabase) Keys ¶
func (db *MemDatabase) Keys() [][]byte
Keys returns [][]byte of mapping keys