Class: SlateDb::Transaction
- Inherits:
-
Object
- Object
- SlateDb::Transaction
- Defined in:
- lib/slatedb/transaction.rb
Instance Method Summary collapse
-
#commit(await_durable: nil, seqnum: nil) ⇒ void
Commit the transaction.
-
#delete(key) ⇒ void
Delete a key within the transaction.
-
#get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) ⇒ String?
Get a value by key within the transaction.
-
#mark_read(keys) ⇒ void
Mark keys as read for conflict detection.
-
#merge(key, value, ttl: nil) ⇒ void
Merge a value within the transaction.
-
#put(key, value, ttl: nil) ⇒ void
Store a key-value pair within the transaction.
-
#scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan a range of keys within the transaction.
-
#scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan all keys with a given prefix within the transaction.
Instance Method Details
#commit(await_durable: nil, seqnum: nil) ⇒ void
This method returns an undefined value.
Commit the transaction.
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/slatedb/transaction.rb', line 162 def commit(await_durable: nil, seqnum: nil) opts = {} opts[:await_durable] = await_durable unless await_durable.nil? opts[:seqnum] = seqnum if seqnum if opts.empty? _commit else (opts) end end |
#delete(key) ⇒ void
This method returns an undefined value.
Delete a key within the transaction.
46 47 48 |
# File 'lib/slatedb/transaction.rb', line 46 def delete(key) _delete(key) end |
#get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) ⇒ String?
Get a value by key within the transaction.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/slatedb/transaction.rb', line 13 def get(key, durability_filter: nil, dirty: nil, cache_blocks: nil) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? if opts.empty? _get(key) else (key, opts) end end |
#mark_read(keys) ⇒ void
This method returns an undefined value.
Mark keys as read for conflict detection.
This explicitly tracks reads for conflict checking in serializable isolation, allowing selective read-write conflict detection even when keys weren’t actually read via get().
141 142 143 |
# File 'lib/slatedb/transaction.rb', line 141 def mark_read(keys) _mark_read(Array(keys)) end |
#merge(key, value, ttl: nil) ⇒ void
This method returns an undefined value.
Merge a value within the transaction.
57 58 59 60 61 62 63 |
# File 'lib/slatedb/transaction.rb', line 57 def merge(key, value, ttl: nil) if ttl (key, value, { ttl: ttl }) else _merge(key, value) end end |
#put(key, value, ttl: nil) ⇒ void
This method returns an undefined value.
Store a key-value pair within the transaction.
33 34 35 36 37 38 39 |
# File 'lib/slatedb/transaction.rb', line 33 def put(key, value, ttl: nil) if ttl (key, value, { ttl: ttl }) else _put(key, value) end end |
#scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan a range of keys within the transaction.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/slatedb/transaction.rb', line 71 def scan(start_key, end_key = nil, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks iter = if opts.empty? _scan(start_key, end_key) else (start_key, end_key, opts) end if block_given? iter.each(&) else iter end end |
#scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil) ⇒ Iterator
Scan all keys with a given prefix within the transaction.
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/slatedb/transaction.rb', line 103 def scan_prefix(prefix, durability_filter: nil, dirty: nil, read_ahead_bytes: nil, cache_blocks: nil, max_fetch_tasks: nil, &) opts = {} opts[:durability_filter] = durability_filter.to_s if durability_filter opts[:dirty] = dirty unless dirty.nil? opts[:read_ahead_bytes] = read_ahead_bytes if read_ahead_bytes opts[:cache_blocks] = cache_blocks unless cache_blocks.nil? opts[:max_fetch_tasks] = max_fetch_tasks if max_fetch_tasks iter = if opts.empty? _scan_prefix(prefix) else (prefix, opts) end if block_given? iter.each(&) else iter end end |