Method: Redis::Commands::Transactions#watch
- Defined in:
- lib/redis/commands/transactions.rb
#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/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 |