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, }.freeze 
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
Returns a new instance of Client.
| 30 31 32 33 34 | # File 'lib/redis/client.rb', line 30 def initialize(*) super @inherit_socket = false @pid = nil end | 
Class Method Details
.config(**kwargs) ⇒ Object
| 21 22 23 | # File 'lib/redis/client.rb', line 21 def config(**kwargs) super(protocol: 2, **kwargs) end | 
.sentinel(**kwargs) ⇒ Object
| 25 26 27 | # File 'lib/redis/client.rb', line 25 def sentinel(**kwargs) super(protocol: 2, **kwargs) end | 
Instance Method Details
#blocking_call_v(timeout, command, &block) ⇒ Object
| 84 85 86 87 88 89 90 91 92 93 94 95 | # File 'lib/redis/client.rb', line 84 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 raise ERROR_MAPPING.fetch(error.class), error., error.backtrace end | 
#call_v(command, &block) ⇒ Object
| 78 79 80 81 82 | # File 'lib/redis/client.rb', line 78 def call_v(command, &block) super(command, &block) rescue ::RedisClient::Error => error raise ERROR_MAPPING.fetch(error.class), error., error.backtrace end | 
#close ⇒ Object
| 117 118 119 120 | # File 'lib/redis/client.rb', line 117 def close super @pid = nil end | 
#db ⇒ Object
| 49 50 51 | # File 'lib/redis/client.rb', line 49 def db config.db end | 
#disable_reconnection(&block) ⇒ Object
| 109 110 111 | # File 'lib/redis/client.rb', line 109 def disable_reconnection(&block) ensure_connected(retryable: false, &block) end | 
#host ⇒ Object
| 53 54 55 | # File 'lib/redis/client.rb', line 53 def host config.host unless config.path end | 
#id ⇒ Object
| 37 38 39 | # File 'lib/redis/client.rb', line 37 def id config.id end | 
#inherit_socket! ⇒ Object
| 113 114 115 | # File 'lib/redis/client.rb', line 113 def inherit_socket! @inherit_socket = true end | 
#multi ⇒ Object
| 103 104 105 106 107 | # File 'lib/redis/client.rb', line 103 def multi super rescue ::RedisClient::Error => error raise ERROR_MAPPING.fetch(error.class), error., error.backtrace end | 
#password ⇒ Object
| 69 70 71 | # File 'lib/redis/client.rb', line 69 def password config.password end | 
#path ⇒ Object
| 61 62 63 | # File 'lib/redis/client.rb', line 61 def path config.path end | 
#pipelined ⇒ Object
| 97 98 99 100 101 | # File 'lib/redis/client.rb', line 97 def pipelined super rescue ::RedisClient::Error => error raise ERROR_MAPPING.fetch(error.class), error., error.backtrace end | 
#port ⇒ Object
| 57 58 59 | # File 'lib/redis/client.rb', line 57 def port config.port unless config.path end | 
#server_url ⇒ Object
| 41 42 43 | # File 'lib/redis/client.rb', line 41 def server_url config.server_url end | 
#timeout ⇒ Object
| 45 46 47 | # File 'lib/redis/client.rb', line 45 def timeout config.read_timeout end | 
#username ⇒ Object
| 65 66 67 | # File 'lib/redis/client.rb', line 65 def username config.username end |