Module: RedisClient::ConnectionMixin

Included in:
RubyConnection
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/connection_mixin.rb

Instance Method Summary collapse

Instance Method Details

#call(command, timeout) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/connection_mixin.rb', line 15

def call(command, timeout)
  @pending_reads += 1
  write(command)
  result = read(timeout)
  @pending_reads -= 1
  if result.is_a?(Error)
    result._set_command(command)
    raise result
  else
    result
  end
end

#call_pipelined(commands, timeouts) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/connection_mixin.rb', line 28

def call_pipelined(commands, timeouts)
  exception = nil

  size = commands.size
  results = Array.new(commands.size)
  @pending_reads += size
  write_multi(commands)

  size.times do |index|
    timeout = timeouts && timeouts[index]
    result = read(timeout)
    @pending_reads -= 1
    if result.is_a?(Error)
      result._set_command(commands[index])
      exception ||= result
    end
    results[index] = result
  end

  if exception
    raise exception
  else
    results
  end
end

#initializeObject



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/connection_mixin.rb', line 5

def initialize
  @pending_reads = 0
end

#revalidateObject



9
10
11
12
13
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/redis-client-0.12.0/lib/redis_client/connection_mixin.rb', line 9

def revalidate
  if @pending_reads == 0 && connected?
    self
  end
end