class Transaction
Context for Redis transaction operations using MULTI/EXEC.
Definitions
def initialize(pool, *arguments)
Initialize a new transaction context.
Signature
-
parameter
pool
Pool
The connection pool to use.
-
parameter
arguments
Array
Additional arguments for the transaction.
Implementation
def initialize(pool, *arguments)
super(pool)
end
def multi
Begin a transaction block.
Implementation
def multi
call("MULTI")
end
def watch(*keys)
Watch keys for changes during the transaction.
Signature
-
parameter
keys
Array(String)
The keys to watch.
Implementation
def watch(*keys)
sync.call("WATCH", *keys)
end
def execute
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.
Implementation
def execute
sync.call("EXEC")
end
def discard
Discard all queued commands in the transaction.
Implementation
def discard
sync.call("DISCARD")
end