123456789_123456789_123456789_123456789_123456789_

Class: Redis::Client

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, RedisClient
Instance Chain:
self, RedisClient
Inherits: RedisClient
  • Object
Defined in: lib/redis/client.rb

Constant Summary

Class Method Summary

Instance Method Summary

Class Method Details

.config(**kwargs)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 22

def config(**kwargs)
  super(protocol: 2, **kwargs)
end

.sentinel(**kwargs)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 26

def sentinel(**kwargs)
  super(protocol: 2, **kwargs, client_implementation: ::RedisClient)
end

.translate_error!(error, mapping: ERROR_MAPPING)

Raises:

  • (redis_error)
[ GitHub ]

  
# File 'lib/redis/client.rb', line 30

def translate_error!(error, mapping: ERROR_MAPPING)
  redis_error = translate_error_class(error.class, mapping: mapping)
  raise redis_error, error.message, error.backtrace
end

.translate_error_class(error_class, mapping: ERROR_MAPPING) (private)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 37

def translate_error_class(error_class, mapping: ERROR_MAPPING)
  mapping.fetch(error_class)
rescue IndexError
  if (client_error = error_class.ancestors.find { |a| mapping[a] })
    mapping[error_class] = mapping[client_error]
  else
    raise
  end
end

Instance Method Details

#blocking_call_v(timeout, command, &block)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 95

def blocking_call_v(timeout, command, &block)
  if timeout && timeout > 0
    # Can't use the command timeout argument as the connection timeout
    # otherwise it would be very racy. So we add the regular read_timeout on top
    # to account for the network delay.
    timeout += config.read_timeout
  end

  super(timeout, command, &block)
rescue ::RedisClient::Error => error
  Client.translate_error!(error)
end

#call_v(command, &block)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 89

def call_v(command, &block)
  super(command, &block)
rescue ::RedisClient::Error => error
  Client.translate_error!(error)
end

#db

[ GitHub ]

  
# File 'lib/redis/client.rb', line 60

def db
  config.db
end

#host

[ GitHub ]

  
# File 'lib/redis/client.rb', line 64

def host
  config.host unless config.path
end

#id

[ GitHub ]

  
# File 'lib/redis/client.rb', line 48

def id
  config.id
end

#inherit_socket!

[ GitHub ]

  
# File 'lib/redis/client.rb', line 120

def inherit_socket!
  @inherit_socket = true
end

#multi(watch: nil)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 114

def multi(watch: nil)
  super
rescue ::RedisClient::Error => error
  Client.translate_error!(error)
end

#password

[ GitHub ]

  
# File 'lib/redis/client.rb', line 80

def password
  config.password
end

#path

[ GitHub ]

  
# File 'lib/redis/client.rb', line 72

def path
  config.path
end

#pipelined(exception: true)

[ GitHub ]

  
# File 'lib/redis/client.rb', line 108

def pipelined(exception: true)
  super
rescue ::RedisClient::Error => error
  Client.translate_error!(error)
end

#port

[ GitHub ]

  
# File 'lib/redis/client.rb', line 68

def port
  config.port unless config.path
end

#server_url

[ GitHub ]

  
# File 'lib/redis/client.rb', line 52

def server_url
  config.server_url
end

#timeout

[ GitHub ]

  
# File 'lib/redis/client.rb', line 56

def timeout
  config.read_timeout
end

#username

[ GitHub ]

  
# File 'lib/redis/client.rb', line 76

def username
  config.username
end