Documentation
¶
Overview ¶
Package boltengine implements a BoltDB engine.
Example ¶
package main import ( "io/ioutil" "log" "os" "path/filepath" "github.com/genjidb/genji" ) func main() { dir, err := ioutil.TempDir("", "bolt") if err != nil { log.Fatal(err) } defer os.RemoveAll(dir) db, err := genji.Open(filepath.Join(dir, "my.db")) 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 ¶
Engine represents a BoltDB engine. Each store is stored in a dedicated bucket.
func NewEngine ¶
NewEngine creates a BoltDB engine. It takes the same argument as Bolt's Open function.
Example ¶
package main import ( "context" "io/ioutil" "log" "os" "path/filepath" "github.com/genjidb/genji" "github.com/genjidb/genji/engine/boltengine" ) func main() { dir, err := ioutil.TempDir("", "bolt") if err != nil { log.Fatal(err) } defer os.RemoveAll(dir) ng, err := boltengine.NewEngine(filepath.Join(dir, "genji.db"), 0o600, nil) if err != nil { log.Fatal(err) } db, err := genji.New(context.Background(), ng) if err != nil { log.Fatal(err) } defer db.Close() }
Output:
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store is an implementation of the engine.Store interface using a bucket.
func (*Store) Delete ¶
Delete a record by key. If not found, returns table.ErrDocumentNotFound. It hides the key without deleting the actual node from the tree, to tree rebalancing during iterations. It then adds it to a sub bucket containing the list of keys to delete when the transaction is committed.
func (*Store) Get ¶
Get returns a value associated with the given key. If not found, returns engine.ErrKeyNotFound.
func (*Store) Iterator ¶ added in v0.9.0
func (s *Store) Iterator(opts engine.IteratorOptions) engine.Iterator
Iterator uses the Bolt bucket cursor.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
A Transaction uses Bolt's transactions.
func (*Transaction) CreateStore ¶
func (t *Transaction) CreateStore(name []byte) error
CreateStore creates a bolt bucket and returns a store. If the store already exists, returns engine.ErrStoreAlreadyExists.
func (*Transaction) DropStore ¶
func (t *Transaction) DropStore(name []byte) error
DropStore deletes the underlying bucket.
func (*Transaction) GetStore ¶
func (t *Transaction) GetStore(name []byte) (engine.Store, error)
GetStore returns a store by name. The store uses a Bolt bucket.
func (*Transaction) Rollback ¶
func (t *Transaction) Rollback() error
Rollback the transaction. Can be used safely after commit.