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.



611
612
613
614
# File 'lib/redis_client.rb', line 611

def initialize(_command_builder)
  super
  @timeouts = nil
end

Instance Method Details

#_coerce!(results) ⇒ Object



642
643
644
645
646
647
648
649
650
651
652
# File 'lib/redis_client.rb', line 642

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)


638
639
640
# File 'lib/redis_client.rb', line 638

def _empty?
  @commands.empty?
end

#_timeoutsObject



634
635
636
# File 'lib/redis_client.rb', line 634

def _timeouts
  @timeouts
end

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



616
617
618
619
620
621
622
623
# File 'lib/redis_client.rb', line 616

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



625
626
627
628
629
630
631
632
# File 'lib/redis_client.rb', line 625

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