Class: SlateDb::Transaction
- Inherits:
-
Object
- Object
- SlateDb::Transaction
- Defined in:
- lib/slatedb/transaction.rb
Instance Method Summary collapse
-
#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.
-
#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.
Instance Method Details
#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 |
#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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/slatedb/transaction.rb', line 56 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 |