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.



581
582
583
584
# File 'lib/redis_client.rb', line 581

def initialize(_command_builder)
  super
  @timeouts = nil
end

Instance Method Details

#_coerce!(results) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
# File 'lib/redis_client.rb', line 612

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)


608
609
610
# File 'lib/redis_client.rb', line 608

def _empty?
  @commands.empty?
end

#_timeoutsObject



604
605
606
# File 'lib/redis_client.rb', line 604

def _timeouts
  @timeouts
end

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



586
587
588
589
590
591
592
593
# File 'lib/redis_client.rb', line 586

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



595
596
597
598
599
600
601
602
# File 'lib/redis_client.rb', line 595

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