You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pass the `Retry` instance in the `retry` parameter when you connect
88
87
to Redis. When you are connecting to a standalone Redis server,
89
88
you can also set the `retry_on_timeout` parameter to `True`
90
-
to retry only after timeout errors, or pass a list of exception
89
+
(to retry only after timeout errors), or pass a list of exception
91
90
types in the `retry_on_error` parameter.
92
91
93
92
```py
@@ -120,38 +119,9 @@ If you specify either `retry_on_timeout` or `retry_on_error` without
120
119
a `retry` parameter, the default is to retry once immediately with no
121
120
backoff.
122
121
123
-
For a connection to a Redis cluster, you can specify a `retry` instance.
124
-
However, the list of exceptions is not configurable and is always set
125
-
to `TimeoutError`, `ConnectionError`, and `ClusterDownError`. You can use
126
-
the `cluster_error_retry_attempts` parameter to specify the number of
127
-
attempts to make after encountering one of these errors:
128
-
129
-
```py
130
-
131
-
```
132
-
133
-
### Timeouts
134
-
135
-
If a network or server error occurs while your code is opening a
136
-
connection or issuing a command, it can end up hanging indefinitely.
137
-
You can prevent this from happening by setting timeouts for socket
138
-
reads and writes and for opening connections.
139
-
140
-
To set a timeout for a connection, use the `JedisPooled` or `JedisPool` constructor with the `timeout` parameter, or use `JedisClientConfig` with the `socketTimeout` and `connectionTimeout` parameters.
141
-
(The socket timeout is the maximum time allowed for reading or writing data while executing a
142
-
command. The connection timeout is the maximum time allowed for establishing a new connection.)
In general, Jedis can throw the following exceptions while executing commands:
197
-
198
-
-`JedisConnectionException` - when the connection to Redis is lost or closed unexpectedly. Configure failover to handle this exception automatically with Resilience4J and the built-in Jedis failover mechanism.
199
-
-`JedisAccessControlException` - when the user does not have the permission to execute the command or the user ID and/or password are incorrect.
200
-
-`JedisDataException` - when there is a problem with the data being sent to or received from the Redis server. Usually, the error message will contain more information about the failed command.
201
-
-`JedisException` - this exception is a catch-all exception that can be thrown for any other unexpected errors.
202
-
203
-
Conditions when `JedisException` can be thrown:
204
-
- Bad return from a health check with the [`PING`]({{< relref "/commands/ping" >}}) command
205
-
- Failure during SHUTDOWN
206
-
- Pub/Sub failure when issuing commands (disconnect)
207
-
- Any unknown server messages
208
-
- Sentinel: can connect to sentinel but master is not monitored or all Sentinels are down.
209
-
- MULTI or DISCARD command failed
210
-
- Shard commands key hash check failed or no Reachable Shards
211
-
- Retry deadline exceeded/number of attempts (Retry Command Executor)
212
-
- POOL - pool exhausted, error adding idle objects, returning broken resources to the pool
213
-
214
-
All the Jedis exceptions are runtime exceptions and in most cases irrecoverable, so in general bubble up to the API capturing the error message.
157
+
you should handle exceptions wherever they can occur.
158
+
159
+
Import the exceptions you need to check from the `redis.exceptions`
160
+
module. The list below describes some of the most common exceptions.
161
+
162
+
-`ConnectionError`: Thrown when a connection attempt fails
163
+
(for example, when connection parameters are invalid or the server
164
+
is unavailable) and sometimes when a [health check](#health-checks)
165
+
fails. There is also a subclass, `AuthenticationError`, specifically
166
+
for authentication failures.
167
+
-`ResponseError`: Thrown when you attempt an operation that has no valid
168
+
response. Examples include executing a command on the wrong type of key
0 commit comments