Class: Async::Redis::Context::Transaction
- Defined in:
- lib/async/redis/context/transaction.rb
Overview
Context for Redis transaction operations using MULTI/EXEC.
Instance Method Summary collapse
-
#discard ⇒ Object
Discard all queued commands in the transaction.
-
#execute ⇒ Object
Execute all queued commands, provided that no watched keys have been modified.
-
#initialize(pool, *arguments) ⇒ Transaction
constructor
Initialize a new transaction context.
-
#multi ⇒ Object
Begin a transaction block.
-
#watch(*keys) ⇒ Object
Watch keys for changes during the transaction.
Methods inherited from Pipeline
#call, #close, #collect, #flush, #read_response, #sync, #write_request
Methods inherited from Generic
#call, #close, #closed?, #read_response, #write_request
Constructor Details
#initialize(pool, *arguments) ⇒ Transaction
Initialize a new transaction context.
17 18 19 |
# File 'lib/async/redis/context/transaction.rb', line 17 def initialize(pool, *arguments) super(pool) end |
Instance Method Details
#discard ⇒ Object
Discard all queued commands in the transaction.
38 39 40 |
# File 'lib/async/redis/context/transaction.rb', line 38 def discard sync.call("DISCARD") end |
#execute ⇒ Object
Execute all queued commands, provided that no watched keys have been modified. It's important to note that even when a command fails, all the other commands in the queue are processed – Redis will not stop the processing of commands.
33 34 35 |
# File 'lib/async/redis/context/transaction.rb', line 33 def execute sync.call("EXEC") end |
#multi ⇒ Object
Begin a transaction block.
22 23 24 |
# File 'lib/async/redis/context/transaction.rb', line 22 def multi call("MULTI") end |
#watch(*keys) ⇒ Object
Watch keys for changes during the transaction.
28 29 30 |
# File 'lib/async/redis/context/transaction.rb', line 28 def watch(*keys) sync.call("WATCH", *keys) end |