LMDB::Database
Inherits Iterable / Enumerable / LMDB::Disposable / Reference / Object
A Database is a key-value store, which is part of an Environment.
By default, each key maps to one value. However, a Database can be
configured to allow duplicate keys, in which case one key will map to
multiple values.
Keys are stored in a sorted order. The order can also be configured upon initialization.
Basic operations on a database are #put, #get and #delete records.
One can also iterate through records using a Cursor.
All operations requires an active transaction opened in #environment.
If no current transaction is found, operations will fail.
Example:
env = LMDB.new "databasedir"
txn = env.transaction
db = env.database "databasename"
db.put "key1", "value1"
db.put "key2", "value2"
db.get "key1" # => "value1"
txn.commit
env.close
Constructors
Instance methods
Create and yields a AbstractCursor to iterate through self, closed when the
block goes out of scope.
The created cursor is associated with the current transaction and self.
It cannot be used after the database is closed, nor when the transaction
has ended. A cursor in a Transaction can be closed before its
transaction ends, and will otherwise be closed when its transaction ends.
A cursor in a ReadOnlyTransaction must be closed explicitly, before or
after its transaction ends. It can be reused with Cursor#renew before
finally closing it.
Deletes the items associated with the given key from self.
Implementors overrides this method to perform resource cleanup If an exception is raised, the resource will not be marked as closed.
Retrieve the value associated with the given key from the database.
If the database supports duplicate keys (DUPSORT), the first value for
the key is returned.
See #cursor to retrieve all items from a given key.
Raises if the key is not in the database.
Retrieve the value associated with the given key from the database.
If the database supports duplicate keys (DUPSORT), the first value for
the key is returned.
See #cursor to retrieve all items from a given key.
Returns nil if the key is not in the database.
Stores the given key/value pair into self.
By default, a matching key replaces contents with given value.
ditto
ditto