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
- .config(**kwargs) ⇒ Object
- .sentinel(**kwargs) ⇒ Object
- .translate_error!(error, mapping: ERROR_MAPPING) ⇒ Object
Instance Method Summary collapse
- #blocking_call_v(timeout, command, &block) ⇒ Object
- #call_v(command, &block) ⇒ Object
- #db ⇒ Object
- #host ⇒ Object
- #id ⇒ Object
- #inherit_socket! ⇒ Object
- #multi(watch: nil) ⇒ Object
- #password ⇒ Object
- #path ⇒ Object
- #pipelined(exception: true) ⇒ Object
- #port ⇒ Object
- #server_url ⇒ Object
- #timeout ⇒ Object
- #username ⇒ Object
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, client_implementation: ::RedisClient) end |
.translate_error!(error, mapping: ERROR_MAPPING) ⇒ Object
30 31 32 33 |
# 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., error.backtrace end |
Instance Method Details
#blocking_call_v(timeout, command, &block) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 |
# 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) ⇒ Object
89 90 91 92 93 |
# 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 ⇒ Object
60 61 62 |
# File 'lib/redis/client.rb', line 60 def db config.db end |
#host ⇒ Object
64 65 66 |
# File 'lib/redis/client.rb', line 64 def host config.host unless config.path end |
#id ⇒ Object
48 49 50 |
# File 'lib/redis/client.rb', line 48 def id config.id end |
#inherit_socket! ⇒ Object
120 121 122 |
# File 'lib/redis/client.rb', line 120 def inherit_socket! @inherit_socket = true end |
#multi(watch: nil) ⇒ Object
114 115 116 117 118 |
# File 'lib/redis/client.rb', line 114 def multi(watch: nil) super rescue ::RedisClient::Error => error Client.translate_error!(error) end |
#password ⇒ Object
80 81 82 |
# File 'lib/redis/client.rb', line 80 def password config.password end |
#path ⇒ Object
72 73 74 |
# File 'lib/redis/client.rb', line 72 def path config.path end |
#pipelined(exception: true) ⇒ Object
108 109 110 111 112 |
# File 'lib/redis/client.rb', line 108 def pipelined(exception: true) super rescue ::RedisClient::Error => error Client.translate_error!(error) end |
#port ⇒ Object
68 69 70 |
# File 'lib/redis/client.rb', line 68 def port config.port unless config.path end |
#server_url ⇒ Object
52 53 54 |
# File 'lib/redis/client.rb', line 52 def server_url config.server_url end |
#timeout ⇒ Object
56 57 58 |
# File 'lib/redis/client.rb', line 56 def timeout config.read_timeout end |
#username ⇒ Object
76 77 78 |
# File 'lib/redis/client.rb', line 76 def username config.username end |