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(filepath.Join(dir, "badger"))) if err != nil { log.Fatal(err) } db, err := genji.New(context.Background(), ng) if err != nil { log.Fatal(err) } defer db.Close()
Output:
Index ¶
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) Get ¶
Get returns a value associated with the given key. If not found, returns engine.ErrKeyNotFound.
func (*Store) Iterator ¶
func (s *Store) Iterator(opts engine.IteratorOptions) engine.Iterator
Iterator uses a Badger iterator with default options. Only one iterator is allowed per read-write transaction.
func (*Store) NextSequence ¶
NextSequence returns a monotonically increasing integer.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
A Transaction uses Badger's transactions.
func (*Transaction) CreateStore ¶
func (t *Transaction) CreateStore(name []byte) error
CreateStore creates a store. If the store already exists, returns engine.ErrStoreAlreadyExists.
func (*Transaction) DropStore ¶
func (t *Transaction) DropStore(name []byte) error
DropStore deletes the store and all its keys.
func (*Transaction) GetStore ¶
func (t *Transaction) GetStore(name []byte) (engine.Store, error)
GetStore returns a store by name.
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
Rollback the transaction. Can be used safely after commit.