Class: Redis::Pipeline::Multi

Inherits:
Redis::Pipeline show all
Defined in:
lib/redis/pipeline.rb

Instance Attribute Summary

Attributes inherited from Redis::Pipeline

#futures

Instance Method Summary collapse

Methods inherited from Redis::Pipeline

#call, #call_pipeline, #initialize, #shutdown?, #with_reconnect, #with_reconnect?, #without_reconnect, #without_reconnect?

Constructor Details

This class inherits a constructor from Redis::Pipeline

Instance Method Details

#commandsObject



86
87
88
# File 'lib/redis/pipeline.rb', line 86

def commands
  [[:multi]] + super + [[:exec]]
end

#finish(replies) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/redis/pipeline.rb', line 70

def finish(replies)
  return if replies.last.nil? # The transaction failed because of WATCH.

  if replies.last.size < futures.size - 2
    # Some command wasn't recognized by Redis.
    raise replies.detect { |r| r.kind_of?(::RuntimeError) }
  end

  super(replies.last) do |reply|
    # Because an EXEC returns nested replies, hiredis won't be able to
    # convert an error reply to a CommandError instance itself. This is
    # specific to MULTI/EXEC, so we solve this here.
    reply.is_a?(::RuntimeError) ? CommandError.new(reply.message) : reply
  end
end