Documentation
¶
Overview ¶
Package wrap provides a thin, opinionated abstraction for the most common LMDB operations.
Index ¶
Constants ¶
View Source
const MapSize = 10 * 1 << 30 // 10 GB
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents a simple LMDB database wrapper.
func New ¶
New creates (or opens) an LMDB environment at the specified directory path and initializes the given databases. If the directory does not exist, it will be created. Remember to call Close() on the returned DB to cleanly shut down the environment. Returns the DB pointer, the number of stale readers cleared, and any error.
func (*DB) GetDBis ¶ added in v1.1.0
GetDBis returns a copy of database names to DBI handle mappings.
func (*DB) Update ¶ added in v1.1.0
Update sends an LMDB operation to the update goroutine and waits for the result.
Usage:
err := db.Update(func(txn *lmdb.Txn) error { dbi := db.GetDBis()["users"] data, err := txn.Get(dbi, []byte("user:123")) if err != nil { return err } if !shouldUpdate(data) { return nil } return txn.Put(dbi, []byte("user:123"), update(data), 0) })
Click to show internal directories.
Click to hide internal directories.