Documentation ¶
Index ¶
- Variables
- type BadgerDB
- func (bdb *BadgerDB) Close() error
- func (bdb *BadgerDB) Get(namespace, key []byte) (value string, err error)
- func (bdb *BadgerDB) Has(namespace, key []byte) (ok bool, err error)
- func (bdb *BadgerDB) Insert(namespace, key, value []byte) error
- func (bdb *BadgerDB) Update(namespace, key, value []byte) error
- type DBInstance
Constants ¶
This section is empty.
Variables ¶
var BadgerAlertNamespace = []byte("alerts")
BadgerAlertNamespace defines the alerts BadgerDB namespace.
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) 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 DBInstance ¶
type DBInstance interface { Get(namespace, key []byte) (value string, err error) Update(namespace, key, value []byte) error Insert(namespace, key, value []byte) error Has(namespace, key []byte) (bool, error) Close() error }
DBInstance defines an embedded key/value store database interface.
var ( DB DBInstance RequestNamespace = []byte("requestNamespace") )
func NewBadgerDB ¶
func NewBadgerDB(dataDir string) (DBInstance, error)
NewBadgerDB returns a new initialized BadgerDB database implementing the DB interface. If the database cannot be initialized, an error will be returned.