Class: RedisClient::Pipeline

Inherits:
Multi
  • Object
show all
Defined in:
lib/redis_client.rb

Instance Method Summary collapse

Methods inherited from Multi

#_blocks, #_commands, #_retryable?, #_size, #call, #call_once, #call_once_v, #call_v

Constructor Details

#initialize(_command_builder) ⇒ Pipeline

Returns a new instance of Pipeline.



663
664
665
666
# File 'lib/redis_client.rb', line 663

def initialize(_command_builder)
  super
  @timeouts = nil
end

Instance Method Details

#_coerce!(results) ⇒ Object



694
695
696
697
698
699
700
701
702
703
704
# File 'lib/redis_client.rb', line 694

def _coerce!(results)
  return results unless results

  @blocks&.each_with_index do |block, index|
    if block
      results[index] = block.call(results[index])
    end
  end

  results
end

#_empty?Boolean

Returns:

  • (Boolean)


690
691
692
# File 'lib/redis_client.rb', line 690

def _empty?
  @commands.empty?
end

#_timeoutsObject



686
687
688
# File 'lib/redis_client.rb', line 686

def _timeouts
  @timeouts
end

#blocking_call(timeout, *command, **kwargs, &block) ⇒ Object



668
669
670
671
672
673
674
675
# File 'lib/redis_client.rb', line 668

def blocking_call(timeout, *command, **kwargs, &block)
  command = @command_builder.generate(command, kwargs)
  @timeouts ||= []
  @timeouts[@commands.size] = timeout
  (@blocks ||= [])[@commands.size] = block if block_given?
  @commands << command
  nil
end

#blocking_call_v(timeout, command, &block) ⇒ Object



677
678
679
680
681
682
683
684
# File 'lib/redis_client.rb', line 677

def blocking_call_v(timeout, command, &block)
  command = @command_builder.generate(command)
  @timeouts ||= []
  @timeouts[@commands.size] = timeout
  (@blocks ||= [])[@commands.size] = block if block_given?
  @commands << command
  nil
end