Module: Oxblood::Commands::Transactions
- Included in:
- Oxblood::Commands
- Defined in:
- lib/oxblood/commands/transactions.rb
Overview
Instance Method Summary collapse
-
#discard ⇒ String, RError
Discard all commands issued after MULTI.
-
#exec ⇒ Array?
Execute all commands issued after MULTI.
-
#multi ⇒ String, RError
Mark the start of a transaction block.
-
#unwatch ⇒ String
Forget about all watched keys.
-
#watch(*keys) ⇒ String
Watch the given keys to determine execution of the MULTI/EXEC block.
Instance Method Details
#discard ⇒ String, RError
Discard all commands issued after MULTI
51 52 53 |
# File 'lib/oxblood/commands/transactions.rb', line 51 def discard run(:DISCARD).tap { connection.transaction_mode = false } end |
#exec ⇒ Array?
Execute all commands issued after MULTI
42 43 44 |
# File 'lib/oxblood/commands/transactions.rb', line 42 def exec run(:EXEC).tap { connection.transaction_mode = false } end |
#multi ⇒ String, RError
Mark the start of a transaction block
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/oxblood/commands/transactions.rb', line 23 def multi response = run(:MULTI).tap do |resp| connection.transaction_mode = true if resp == 'OK' end if block_given? yield exec else response end end |
#unwatch ⇒ String
Forget about all watched keys
74 75 76 |
# File 'lib/oxblood/commands/transactions.rb', line 74 def unwatch run(:UNWATCH) end |
#watch(*keys) ⇒ String
Watch the given keys to determine execution of the MULTI/EXEC block
66 67 68 |
# File 'lib/oxblood/commands/transactions.rb', line 66 def watch(*keys) run(:WATCH, keys) end |