Documentation ¶
Index ¶
- type BadgerDB
- func (bdb *BadgerDB) All(prefix []byte) ([][]byte, error)
- func (bdb *BadgerDB) Close() error
- func (bdb *BadgerDB) Count(prefix []byte) (int, error)
- func (bdb *BadgerDB) Each(prefix []byte, callback KVStoreEachFunc) error
- func (bdb *BadgerDB) ErrNotFound() error
- func (bdb *BadgerDB) Get(key []byte) ([]byte, error)
- func (bdb *BadgerDB) Has(key []byte) (ok bool, err error)
- func (bdb *BadgerDB) Remove(prefix []byte) error
- func (bdb *BadgerDB) Set(key, value []byte) error
- func (bdb *BadgerDB) SetEx(key, value []byte, ttl time.Duration) error
- type KVStore
- type KVStoreEachFunc
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 is a wrapper around a BadgerDB backend database that implements the DB interface.
func (*BadgerDB) Close ¶
Close implements the DB interface. It closes the connection to the underlying BadgerDB database as well as invoking the context's cancel function.
func (*BadgerDB) Each ¶
func (bdb *BadgerDB) Each(prefix []byte, callback KVStoreEachFunc) error
Each iterates over all items that match namespace and prefix
func (*BadgerDB) ErrNotFound ¶
ErrNotFound is the error badger returns when it can't find a key in the database
func (*BadgerDB) Get ¶
Get implements the DB interface. It attempts to get a value for a given key and namespace. If the key does not exist in the provided namespace, an error is returned, otherwise the retrieved value.
func (*BadgerDB) Has ¶
Has implements the DB interface. It returns a boolean reflecting if the datbase has a given key for a namespace or not. An error is only returned if an error to Get would be returned that is not of type badger.ErrKeyNotFound.
type KVStore ¶
type KVStore interface { Get(key []byte) (value []byte, err error) SetEx(key, value []byte, ttl time.Duration) error Set(key, value []byte) error Has(key []byte) (bool, error) All(prefix []byte) ([][]byte, error) Count(prefix []byte) (int, error) Remove(prefix []byte) error Each(prefix []byte, callback KVStoreEachFunc) error ErrNotFound() error Close() error }
KVStore defines an embedded key/value store database interface.
type KVStoreEachFunc ¶
type KVStoreEachFunc func([]byte)
KVStoreEachFunc is the function that gets called on each item in the Each function