Documentation ¶
Overview ¶
Package badgerengine implements a Badger engine.
Example ¶
dir, err := ioutil.TempDir("", "badger") if err != nil { log.Fatal(err) } defer os.RemoveAll(dir) ng, err := badgerengine.NewEngine(badger.DefaultOptions(path.Join(dir, "badger"))) if err != nil { log.Fatal(err) } db, err := genji.New(ng) if err != nil { log.Fatal(err) } defer db.Close()
Output:
Index ¶
- type Engine
- type Store
- func (s *Store) AscendGreaterOrEqual(pivot []byte, fn func(k, v []byte) error) error
- func (s *Store) Delete(k []byte) error
- func (s *Store) DescendLessOrEqual(pivot []byte, fn func(k, v []byte) error) error
- func (s *Store) Get(k []byte) ([]byte, error)
- func (s *Store) Put(k, v []byte) error
- func (s *Store) Truncate() error
- type Transaction
- func (t *Transaction) Commit() error
- func (t *Transaction) CreateStore(name string) error
- func (t *Transaction) DropStore(name string) error
- func (t *Transaction) GetStore(name string) (engine.Store, error)
- func (t *Transaction) ListStores(prefix string) ([]string, error)
- func (t *Transaction) Rollback() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
DB *badger.DB
}
Engine represents a Badger engine.
func NewEngine ¶
NewEngine creates a Badger engine. It takes the same argument as Badger's Open function.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store is an implementation of the engine.Store interface.
func (*Store) AscendGreaterOrEqual ¶
AscendGreaterOrEqual seeks for the pivot and then goes through all the subsequent key value pairs in increasing order and calls the given function for each pair. If the given function returns an error, the iteration stops and returns that error. If the pivot is nil, starts from the beginning.
func (*Store) DescendLessOrEqual ¶
DescendLessOrEqual seeks for the pivot and then goes through all the subsequent key value pairs in descreasing order and calls the given function for each pair. If the given function returns an error, the iteration stops and returns that error. If the pivot is nil, starts from the end.
func (*Store) Get ¶
Get returns a value associated with the given key. If not found, returns engine.ErrKeyNotFound.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
A Transaction uses Badger's transactions.
func (*Transaction) CreateStore ¶
func (t *Transaction) CreateStore(name string) error
CreateStore creates a store. If the store already exists, returns engine.ErrStoreAlreadyExists.
func (*Transaction) DropStore ¶
func (t *Transaction) DropStore(name string) error
DropStore deletes the store and all its keys.
func (*Transaction) GetStore ¶
func (t *Transaction) GetStore(name string) (engine.Store, error)
GetStore returns a store by name.
func (*Transaction) ListStores ¶
func (t *Transaction) ListStores(prefix string) ([]string, error)
ListStores returns a list of all the store names.
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
Rollback the transaction. Can be used safely after commit.