Method: Redis::Commands::Transactions#multi

Defined in:
lib/redis/commands/transactions.rb

#multi {|multi| ... } ⇒ Array<...>

Mark the start of a transaction block.

Examples:

With a block

redis.multi do |multi|
  multi.set("key", "value")
  multi.incr("counter")
end # => ["OK", 6]

Yields:

  • (multi)

    the commands that are called inside this block are cached and written to the server upon returning from it

Yield Parameters:

Returns:

  • (Array<...>)
    • an array with replies

See Also:



23
24
25
26
27
28
29
# File '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