# File lib/redis/pipeline.rb, line 11 def initialize @with_reconnect = true @shutdown = false @futures = [] end
# File lib/redis/pipeline.rb, line 29 def call(command, &block) # A pipeline that contains a shutdown should not raise ECONNRESET when # the connection is gone. @shutdown = true if command.first == :shutdown future = Future.new(command, block) @futures << future future end
# File lib/redis/pipeline.rb, line 38 def call_pipeline(pipeline) @shutdown = true if pipeline.shutdown? @futures.concat(pipeline.futures) nil end
# File lib/redis/pipeline.rb, line 44 def commands @futures.map { |f| f._command } end
# File lib/redis/pipeline.rb, line 57 def finish(replies, &blk) if blk futures.each_with_index.map do |future, i| future._set(blk.call(replies[i])) end else futures.each_with_index.map do |future, i| future._set(replies[i]) end end end
# File lib/redis/pipeline.rb, line 25 def shutdown? @shutdown end
# File lib/redis/pipeline.rb, line 48 def with_reconnect(val=true) @with_reconnect = false unless val yield end
# File lib/redis/pipeline.rb, line 17 def with_reconnect? @with_reconnect end
# File lib/redis/pipeline.rb, line 53 def without_reconnect(&blk) with_reconnect(false, &blk) end
# File lib/redis/pipeline.rb, line 21 def without_reconnect? !@with_reconnect end