class RedisClient::Multi
def _blocks
def _blocks @blocks end
def _coerce!(results)
def _coerce!(results) results&.each_with_index do |result, index| if result.is_a?(CommandError) result._set_command(@commands[index + 1]) raise result end if @blocks && block = @blocks[index + 1] results[index] = block.call(result) end end results end
def _commands
def _commands @commands end
def _empty?
def _empty? @commands.size <= 2 end
def _retryable?
def _retryable? @retryable end
def _size
def _size @commands.size end
def _timeouts
def _timeouts nil end
def call(*command, **kwargs, &block)
def call(*command, **kwargs, &block) command = @command_builder.generate(command, kwargs) (@blocks ||= [])[@commands.size] = block if block_given? @commands << command nil end
def call_once(*command, **kwargs, &block)
def call_once(*command, **kwargs, &block) command = @command_builder.generate(command, kwargs) @retryable = false (@blocks ||= [])[@commands.size] = block if block_given? @commands << command nil end
def call_once_v(command, &block)
def call_once_v(command, &block) command = @command_builder.generate(command) @retryable = false (@blocks ||= [])[@commands.size] = block if block_given? @commands << command nil end
def call_v(command, &block)
def call_v(command, &block) command = @command_builder.generate(command) (@blocks ||= [])[@commands.size] = block if block_given? @commands << command nil end
def initialize(command_builder)
def initialize(command_builder) @command_builder = command_builder @size = 0 @commands = [] @blocks = nil @retryable = true end