Documentation
¶
Index ¶
- type BadgerDB
- func (bdb *BadgerDB) Close() error
- func (bdb *BadgerDB) Del(key []byte) error
- func (bdb *BadgerDB) GenID() (id []byte, err error)
- func (bdb *BadgerDB) Get(key []byte) (item Item, err error)
- func (bdb *BadgerDB) GetAll() (items map[string]Item, err error)
- func (bdb *BadgerDB) GetExpiration(items map[string]Item) (itemss map[string]ItemS)
- func (bdb *BadgerDB) Has(key []byte) (exists bool, err error)
- func (bdb *BadgerDB) KeyCount() int
- func (bdb *BadgerDB) Set(key, value []byte, ttl time.Duration) error
- type DB
- type Item
- type ItemS
- type ItemST
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
}
func (*BadgerDB) Close ¶
Close implements the DB interface. Closes the DB connection and invokes ctx cancel.
func (*BadgerDB) GenID ¶
GenID implements the DB interface. It generates a random id, retrying until it generates one which does not already exist in the DB or returns error.
func (*BadgerDB) GetExpiration ¶
GetExpiration implements the DB interface, for a given map of Items it will convert Item.Expiry from a time.Duration to a string and return a new collection of ItemS (map[string]ItemS) or error.
func (*BadgerDB) Has ¶
Has implements the DB interface, returns bool if key is present or not, Error only returned if not badger.ErrKeyNotFound.
type DB ¶
type DB interface { Get(key []byte) (item Item, err error) Set(key, value []byte, ttl time.Duration) error Del(key []byte) error Has(key []byte) (bool, error) KeyCount() int GetAll() (items map[string]Item, err error) GenID() (id []byte, err error) GetExpiration(items map[string]Item) (itemss map[string]ItemS) Close() error }
var KV DB
func NewBadgerDB ¶
NewBadgerDB returns a new, initialized BadgerDB database implementing DB.
Click to show internal directories.
Click to hide internal directories.