Documentation
¶
Overview ¶
Package badgerd provides a BadgerDB driver for go-shelve.
Index ¶
- func Open(opts badger.Options) (*badger.DB, error)
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(key []byte) error
- func (s *Store) Get(key []byte) ([]byte, error)
- func (s *Store) Has(key []byte) (bool, error)
- func (s *Store) Items(start []byte, order int, fn func(key, value []byte) (bool, error)) error
- func (s *Store) Len() int64
- func (s *Store) Put(key, value []byte) error
- func (s *Store) Sync() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a BadgerDB driver for shelve.Shelf.
func NewDefault ¶
NewDefault creates a new BadgerDB store with sensible default values.
func (*Store) Get ¶
Get retrieves the value associated with a key from the store. If the key is not found, it returns nil.
func (*Store) Items ¶
Items iterates over key-value pairs in the database, calling fn(k, v) for each pair in the sequence. The iteration stops early if the function fn returns false.
The start parameter specifies the key from which the iteration should start. If the start parameter is nil, the iteration will begin from the first key in the database.
The order parameter specifies the order in which the items should be yielded. A negative value for order will cause the iteration to occur in reverse order.
The key-value pairs are returned in lexicographically sorted order.
The value parameter must only be used inside fn, as it is reused during the iteration.
func (*Store) Len ¶
Len returns the number of items in the store. It returns -1 if an error occurs.
Warning: BadgerDB doesn't provide a method to count the number of stored items and Len will iterate through the entire DB to retrieve this information.
See: https://discuss.dgraph.io/t/count-of-items-in-db/7549/2