Class: Redis::Client
- Inherits:
-
RedisClient
- Object
- RedisClient
- Redis::Client
- 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
- #blocking_call_v(timeout, command, &block) ⇒ Object
- #call_v(command, &block) ⇒ Object
- #close ⇒ Object
- #db ⇒ Object
- #disable_reconnection(&block) ⇒ Object
- #host ⇒ Object
- #id ⇒ Object
- #inherit_socket! ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #multi ⇒ Object
- #password ⇒ Object
- #path ⇒ Object
- #pipelined ⇒ Object
- #port ⇒ Object
- #server_url ⇒ Object
- #timeout ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize ⇒ Client
31 32 33 34 35 |
# File 'lib/redis/client.rb', line 31 def initialize(*) super @inherit_socket = false @pid = nil end |
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
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/redis/client.rb', line 85 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 an extra 100ms to account for # the network delay. timeout += 0.1 end super(timeout, command, &block) rescue ::RedisClient::Error => error translate_error!(error) end |
#call_v(command, &block) ⇒ Object
79 80 81 82 83 |
# File 'lib/redis/client.rb', line 79 def call_v(command, &block) super(command, &block) rescue ::RedisClient::Error => error translate_error!(error) end |
#close ⇒ Object
118 119 120 121 |
# File 'lib/redis/client.rb', line 118 def close super @pid = nil end |
#db ⇒ Object
50 51 52 |
# File 'lib/redis/client.rb', line 50 def db config.db end |
#disable_reconnection(&block) ⇒ Object
110 111 112 |
# File 'lib/redis/client.rb', line 110 def disable_reconnection(&block) ensure_connected(retryable: false, &block) end |
#host ⇒ Object
54 55 56 |
# File 'lib/redis/client.rb', line 54 def host config.host unless config.path end |
#id ⇒ Object
38 39 40 |
# File 'lib/redis/client.rb', line 38 def id config.id end |
#inherit_socket! ⇒ Object
114 115 116 |
# File 'lib/redis/client.rb', line 114 def inherit_socket! @inherit_socket = true end |
#multi ⇒ Object
104 105 106 107 108 |
# File 'lib/redis/client.rb', line 104 def multi super rescue ::RedisClient::Error => error translate_error!(error) end |
#password ⇒ Object
70 71 72 |
# File 'lib/redis/client.rb', line 70 def password config.password end |
#path ⇒ Object
62 63 64 |
# File 'lib/redis/client.rb', line 62 def path config.path end |
#pipelined ⇒ Object
98 99 100 101 102 |
# File 'lib/redis/client.rb', line 98 def pipelined super rescue ::RedisClient::Error => error translate_error!(error) end |
#port ⇒ Object
58 59 60 |
# File 'lib/redis/client.rb', line 58 def port config.port unless config.path end |
#server_url ⇒ Object
42 43 44 |
# File 'lib/redis/client.rb', line 42 def server_url config.server_url end |
#timeout ⇒ Object
46 47 48 |
# File 'lib/redis/client.rb', line 46 def timeout config.read_timeout end |
#username ⇒ Object
66 67 68 |
# File 'lib/redis/client.rb', line 66 def username config.username end |