Class: Redis::Client

Inherits:
RedisClient
  • Object
show all
Defined in:
lib/redis/client.rb

Constant Summary collapse

ERROR_MAPPING =
{
  RedisClient::ConnectionError => Redis::ConnectionError,
  RedisClient::CommandError => Redis::CommandError,
  RedisClient::ReadTimeoutError => Redis::TimeoutError,
  RedisClient::CannotConnectError => Redis::CannotConnectError,
  RedisClient::AuthenticationError => Redis::CannotConnectError,
  RedisClient::FailoverError => Redis::CannotConnectError,
  RedisClient::PermissionError => Redis::PermissionError,
  RedisClient::WrongTypeError => Redis::WrongTypeError,
  RedisClient::ReadOnlyError => Redis::ReadOnlyError,
  RedisClient::ProtocolError => Redis::ProtocolError,
  RedisClient::OutOfMemoryError => Redis::OutOfMemoryError,
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config(**kwargs) ⇒ Object



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

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

.sentinel(**kwargs) ⇒ Object



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

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

Instance Method Details

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



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/redis/client.rb', line 78

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
  translate_error!(error)
end

#call_v(command, &block) ⇒ Object



72
73
74
75
76
# File 'lib/redis/client.rb', line 72

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

#dbObject



43
44
45
# File 'lib/redis/client.rb', line 43

def db
  config.db
end

#disable_reconnection(&block) ⇒ Object



103
104
105
# File 'lib/redis/client.rb', line 103

def disable_reconnection(&block)
  ensure_connected(retryable: false, &block)
end

#hostObject



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

def host
  config.host unless config.path
end

#idObject



31
32
33
# File 'lib/redis/client.rb', line 31

def id
  config.id
end

#inherit_socket!Object



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

def inherit_socket!
  @inherit_socket = true
end

#multiObject



97
98
99
100
101
# File 'lib/redis/client.rb', line 97

def multi
  super
rescue ::RedisClient::Error => error
  translate_error!(error)
end

#passwordObject



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

def password
  config.password
end

#pathObject



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

def path
  config.path
end

#pipelinedObject



91
92
93
94
95
# File 'lib/redis/client.rb', line 91

def pipelined
  super
rescue ::RedisClient::Error => error
  translate_error!(error)
end

#portObject



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

def port
  config.port unless config.path
end

#server_urlObject



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

def server_url
  config.server_url
end

#timeoutObject



39
40
41
# File 'lib/redis/client.rb', line 39

def timeout
  config.read_timeout
end

#usernameObject



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

def username
  config.username
end