abstract struct LMDB::AbstractCursor

Overview

A Cursor points to records in a database, and is used to iterate through the records in a Database.

Cursors are created in the context of a Transaction, and should only be used as long as that transaction is active. In other words, after a Transaction#commit or Transaction#abort, the cursors created while that transaction was active are no longer usable.

To create a cursor, see Database#cursor.

Example:

LMDB.open "databasedir" do |env|
  env.database "databasename" do |db|
    db.cursor do |cursor|
      r1 = cursor.last         # => content of the last record
      r2 = cursor.first        # => content of the first record
      key, _ = cursor.next     # => content of the second record
      cursor.put key, "newval" # => replace the value of last record
    end
  end
end

Direct Known Subclasses

Defined in:

lmdb/cursor.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(transaction : AbstractTransaction, database : Database) #

[View source]

Instance Method Detail

def close #

Close this cursor.

self must not be used after this call.


[View source]
abstract def readonly? : Bool #

Whether self is a readonly cursor.


[View source]
def to_unsafe : Pointer(Void) #

[View source]