Module: Redis::Commands::Transactions
- Included in:
- Redis::Commands
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb
Instance Method Summary collapse
-
#discard ⇒ String
Discard all commands issued after MULTI.
-
#exec ⇒ nil, Array<...>
Execute all commands issued after MULTI.
-
#multi {|multi| ... } ⇒ Array<...>
Mark the start of a transaction block.
-
#unwatch ⇒ String
Forget about all watched keys.
-
#watch(*keys) ⇒ Object, String
Watch the given keys to determine execution of the MULTI/EXEC block.
Instance Method Details
#discard ⇒ String
Discard all commands issued after MULTI.
110 111 112 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb', line 110 def discard send_command([:discard]) end |
#exec ⇒ nil, Array<...>
Execute all commands issued after MULTI.
Only call this method when ‘#multi` was called without a block.
100 101 102 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb', line 100 def exec send_command([:exec]) end |
#multi {|multi| ... } ⇒ Array<...>
Mark the start of a transaction block.
23 24 25 26 27 28 29 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb', line 23 def multi synchronize do |client| client.multi do |raw_transaction| yield MultiConnection.new(raw_transaction) end end end |
#unwatch ⇒ String
Forget about all watched keys.
86 87 88 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb', line 86 def unwatch send_command([:unwatch]) end |
#watch(*keys) ⇒ Object, String
Watch the given keys to determine execution of the MULTI/EXEC block.
Using a block is optional, but is necessary for thread-safety.
An ‘#unwatch` is automatically issued if an exception is raised within the block that is a subclass of StandardError and is not a ConnectionError.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-5.0.5/lib/redis/commands/transactions.rb', line 61 def watch(*keys) synchronize do |client| res = client.call_v([:watch] + keys) if block_given? begin yield(self) rescue ConnectionError raise rescue StandardError unwatch raise end else res end end end |