class Redis::Client
def call_pipelined(commands)
def call_pipelined(commands) return [] if commands.empty? # The method #ensure_connected (called from #process) reconnects once on # I/O errors. To make an effort in making sure that commands are not # executed more than once, only allow reconnection before the first reply # has been read. When an error occurs after the first reply has been # read, retrying would re-execute the entire pipeline, thus re-issuing # already successfully executed commands. To circumvent this, don't retry # after the first reply has been read successfully. result = Array.new(commands.size) reconnect = @reconnect begin exception = nil process(commands) do result[0] = read @reconnect = false (commands.size - 1).times do |i| reply = read result[i + 1] = reply exception = reply if exception.nil? && reply.is_a?(CommandError) end end raise exception if exception ensure @reconnect = reconnect end result end