class FDB::Transaction
Attributes
options[R]
snapshot[R]
Public Class Methods
new(tpointer, db)
click to toggle source
Calls superclass method
FDB::TransactionRead::new
# File lib/fdbimpl.rb, line 863 def initialize(tpointer, db) super(tpointer, db, 0) @snapshot = TransactionRead.new(tpointer, db, 1) @options = TransactionOptions.new lambda { |code, param| FDBC.check_error FDBC.fdb_transaction_set_option(@tpointer, code, param, param.nil? ? 0 : param.bytesize) } ObjectSpace.undefine_finalizer self end
Public Instance Methods
add_read_conflict_key(key)
click to toggle source
# File lib/fdbimpl.rb, line 887 def add_read_conflict_key(key) key = FDB.key_to_bytes(key) add_read_conflict_range(key, key + "\x00") end
add_read_conflict_range(bkey, ekey)
click to toggle source
# File lib/fdbimpl.rb, line 881 def add_read_conflict_range(bkey, ekey) bkey = FDB.key_to_bytes(bkey) ekey = FDB.key_to_bytes(ekey) FDBC.check_error FDBC.fdb_transaction_add_conflict_range(@tpointer, bkey, bkey.bytesize, ekey, ekey.bytesize, @@ConflictRangeType["READ"][0]) end
add_write_conflict_key(key)
click to toggle source
# File lib/fdbimpl.rb, line 898 def add_write_conflict_key(key) key = FDB.key_to_bytes(key) add_write_conflict_range(key, key + "\x00") end
add_write_conflict_range(bkey, ekey)
click to toggle source
# File lib/fdbimpl.rb, line 892 def add_write_conflict_range(bkey, ekey) bkey = FDB.key_to_bytes(bkey) ekey = FDB.key_to_bytes(ekey) FDBC.check_error FDBC.fdb_transaction_add_conflict_range(@tpointer, bkey, bkey.bytesize, ekey, ekey.bytesize, @@ConflictRangeType["WRITE"][0]) end
cancel()
click to toggle source
# File lib/fdbimpl.rb, line 952 def cancel FDBC.fdb_transaction_cancel @tpointer end
clear(key)
click to toggle source
# File lib/fdbimpl.rb, line 917 def clear(key) key = FDB.key_to_bytes(key) FDBC.fdb_transaction_clear(@tpointer, key, key.bytesize) end
clear_range(bkey, ekey)
click to toggle source
# File lib/fdbimpl.rb, line 922 def clear_range(bkey, ekey) bkey = FDB.key_to_bytes(bkey) ekey = FDB.key_to_bytes(ekey) FDBC.fdb_transaction_clear_range(@tpointer, bkey || "", bkey && bkey.bytesize || 0, ekey || "", ekey && ekey.bytesize || 0) end
clear_range_start_with(prefix)
click to toggle source
# File lib/fdbimpl.rb, line 928 def clear_range_start_with(prefix) prefix = FDB.key_to_bytes(prefix) prefix = prefix.dup.force_encoding "BINARY" clear_range(prefix, FDB.strinc(prefix)) end
commit()
click to toggle source
# File lib/fdbimpl.rb, line 903 def commit FutureNil.new(FDBC.fdb_transaction_commit(@tpointer)) end
get_committed_version()
click to toggle source
# File lib/fdbimpl.rb, line 938 def get_committed_version version = FFI::MemoryPointer.new :int64 FDBC.check_error FDBC.fdb_transaction_get_committed_version(@tpointer, version) version.read_long_long end
get_versionstamp()
click to toggle source
# File lib/fdbimpl.rb, line 944 def get_versionstamp Key.new(FDBC.fdb_transaction_get_versionstamp(@tpointer)) end
on_error(e)
click to toggle source
# File lib/fdbimpl.rb, line 912 def on_error(e) raise e if !e.kind_of? Error FutureNil.new(FDBC.fdb_transaction_on_error(@tpointer, e.code)) end
reset()
click to toggle source
# File lib/fdbimpl.rb, line 948 def reset FDBC.fdb_transaction_reset @tpointer end
set(key, value)
click to toggle source
# File lib/fdbimpl.rb, line 874 def set(key, value) key = FDB.key_to_bytes(key) value = FDB.value_to_bytes(value) FDBC.fdb_transaction_set(@tpointer, key, key.bytesize, value, value.bytesize) end
Also aliased as: []=
set_read_version(version)
click to toggle source
# File lib/fdbimpl.rb, line 934 def set_read_version(version) FDBC.fdb_transaction_set_read_version(@tpointer, version) end
watch(key)
click to toggle source
# File lib/fdbimpl.rb, line 907 def watch(key) key = FDB.key_to_bytes(key) FutureNil.new(FDBC.fdb_transaction_watch(@tpointer, key, key.bytesize)) end
Private Instance Methods
atomic_op(code, key, param)
click to toggle source
# File lib/fdbimpl.rb, line 956 def atomic_op(code, key, param) key = FDB.key_to_bytes(key) param = FDB.value_to_bytes(param) FDBC.fdb_transaction_atomic_op(@tpointer, key, key.bytesize, param, param.bytesize, code) end