redis 6.0.0b1__tar.gz → 6.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {redis-6.0.0b1 → redis-6.1.0}/.gitignore +1 -0
- {redis-6.0.0b1 → redis-6.1.0}/PKG-INFO +14 -8
- {redis-6.0.0b1 → redis-6.1.0}/README.md +12 -6
- {redis-6.0.0b1 → redis-6.1.0}/pyproject.toml +1 -1
- {redis-6.0.0b1 → redis-6.1.0}/redis/__init__.py +9 -1
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/resp3.py +2 -2
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/client.py +83 -71
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/cluster.py +74 -50
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/connection.py +43 -17
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/retry.py +12 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/sentinel.py +2 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/backoff.py +54 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/client.py +99 -89
- {redis-6.0.0b1 → redis-6.1.0}/redis/cluster.py +1085 -359
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/core.py +105 -105
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/helpers.py +19 -6
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/json/__init__.py +1 -1
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/json/commands.py +8 -8
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/redismodules.py +27 -9
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/commands.py +2 -2
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/timeseries/__init__.py +1 -1
- redis-6.1.0/redis/commands/vectorset/__init__.py +46 -0
- redis-6.1.0/redis/commands/vectorset/commands.py +367 -0
- redis-6.1.0/redis/commands/vectorset/utils.py +94 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/connection.py +46 -13
- {redis-6.0.0b1 → redis-6.1.0}/redis/exceptions.py +18 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/retry.py +25 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/sentinel.py +2 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/utils.py +7 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_bloom.py +28 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_cluster.py +82 -38
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_connect.py +12 -1
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_connection_pool.py +3 -3
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_lock.py +2 -2
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_pipeline.py +16 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_search.py +12 -6
- redis-6.1.0/tests/test_asyncio/test_ssl.py +56 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_timeseries.py +39 -0
- redis-6.1.0/tests/test_asyncio/test_vsets.py +869 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_bloom.py +28 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_cache.py +2 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_cluster.py +139 -45
- redis-6.1.0/tests/test_cluster_transaction.py +392 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_connect.py +10 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_connection_pool.py +3 -3
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_pipeline.py +16 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_retry.py +62 -3
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_ssl.py +30 -1
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_timeseries.py +38 -1
- redis-6.1.0/tests/test_vsets.py +867 -0
- {redis-6.0.0b1 → redis-6.1.0}/LICENSE +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/dev_requirements.txt +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/base.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/commands.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/encoders.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/helpers.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/hiredis.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/resp2.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/_parsers/socket.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/lock.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/asyncio/utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/auth/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/auth/err.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/auth/idp.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/auth/token.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/auth/token_manager.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/cache.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/bf/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/bf/commands.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/bf/info.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/cluster.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/json/_util.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/json/decoders.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/json/path.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/_util.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/aggregation.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/dialect.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/document.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/field.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/index_definition.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/profile_information.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/query.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/querystring.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/reducers.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/result.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/search/suggestion.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/sentinel.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/timeseries/commands.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/timeseries/info.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/commands/timeseries/utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/crc.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/credentials.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/event.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/lock.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/ocsp.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/py.typed +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/redis/typing.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/conftest.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/entraid_utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/mocks.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/ssl_utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/compat.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/conftest.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/mocks.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_commands.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_connection.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_credentials.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_cwe_404.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_encoding.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_hash.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_json.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_monitor.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_pubsub.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_retry.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_scripting.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_sentinel.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_sentinel_managed_connection.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/test_utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/testdata/jsontestdata.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/testdata/titles.csv +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_asyncio/testdata/will_play_text.csv.bz2 +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_auth/__init__.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_auth/test_token.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_auth/test_token_manager.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_backoff.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_command_parser.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_commands.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_connection.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_credentials.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_encoding.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_function.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_hash.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_helpers.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_json.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_lock.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_monitor.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_multiprocessing.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_parsers/test_helpers.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_pubsub.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_scripting.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_search.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_sentinel.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/test_utils.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/testdata/jsontestdata.py +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/testdata/titles.csv +0 -0
- {redis-6.0.0b1 → redis-6.1.0}/tests/testdata/will_play_text.csv.bz2 +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: redis
|
|
3
|
-
Version: 6.0
|
|
3
|
+
Version: 6.1.0
|
|
4
4
|
Summary: Python client for Redis database and key-value store
|
|
5
5
|
Project-URL: Changes, https://github.com/redis/redis-py/releases
|
|
6
6
|
Project-URL: Code, https://github.com/redis/redis-py
|
|
@@ -32,7 +32,7 @@ Requires-Dist: async-timeout>=4.0.3; python_full_version < '3.11.3'
|
|
|
32
32
|
Provides-Extra: hiredis
|
|
33
33
|
Requires-Dist: hiredis>=3.0.0; extra == 'hiredis'
|
|
34
34
|
Provides-Extra: jwt
|
|
35
|
-
Requires-Dist: pyjwt
|
|
35
|
+
Requires-Dist: pyjwt>=2.9.0; extra == 'jwt'
|
|
36
36
|
Provides-Extra: ocsp
|
|
37
37
|
Requires-Dist: cryptography>=36.0.1; extra == 'ocsp'
|
|
38
38
|
Requires-Dist: pyopenssl>=20.0.1; extra == 'ocsp'
|
|
@@ -72,10 +72,16 @@ The Python interface to the Redis key-value store.
|
|
|
72
72
|
|
|
73
73
|
## Installation
|
|
74
74
|
|
|
75
|
-
Start a redis via docker:
|
|
75
|
+
Start a redis via docker (for Redis versions >= 8.0):
|
|
76
76
|
|
|
77
77
|
``` bash
|
|
78
|
-
docker run -p 6379:6379 -it redis
|
|
78
|
+
$ docker run -p 6379:6379 -it redis:latest
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Start a redis via docker (for Redis versions < 8.0):
|
|
82
|
+
|
|
83
|
+
``` bash
|
|
84
|
+
$ docker run -p 6379:6379 -it redis/redis-stack:latest
|
|
79
85
|
```
|
|
80
86
|
|
|
81
87
|
To install redis-py, simply:
|
|
@@ -95,7 +101,7 @@ Looking for a high-level library to handle object mapping? See [redis-om-python]
|
|
|
95
101
|
|
|
96
102
|
## Supported Redis Versions
|
|
97
103
|
|
|
98
|
-
The most recent version of this library supports
|
|
104
|
+
The most recent version of this library supports Redis version [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES), [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES) and [8.0](https://github.com/redis/redis/blob/8.0/00-RELEASENOTES).
|
|
99
105
|
|
|
100
106
|
The table below highlights version compatibility of the most-recent library versions and redis versions.
|
|
101
107
|
|
|
@@ -196,8 +202,8 @@ The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs
|
|
|
196
202
|
|
|
197
203
|
### Redis’ search and query capabilities default dialect
|
|
198
204
|
|
|
199
|
-
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
|
|
200
|
-
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
|
|
205
|
+
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
|
|
206
|
+
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
|
|
201
207
|
|
|
202
208
|
**Important**: Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by configuring the client accordingly.
|
|
203
209
|
|
|
@@ -245,4 +251,4 @@ Special thanks to:
|
|
|
245
251
|
system.
|
|
246
252
|
- Paul Hubbard for initial packaging support.
|
|
247
253
|
|
|
248
|
-
[](https://redis.io)
|
|
254
|
+
[](https://redis.io)
|
|
@@ -31,10 +31,16 @@ The Python interface to the Redis key-value store.
|
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
34
|
-
Start a redis via docker:
|
|
34
|
+
Start a redis via docker (for Redis versions >= 8.0):
|
|
35
35
|
|
|
36
36
|
``` bash
|
|
37
|
-
docker run -p 6379:6379 -it redis
|
|
37
|
+
$ docker run -p 6379:6379 -it redis:latest
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Start a redis via docker (for Redis versions < 8.0):
|
|
41
|
+
|
|
42
|
+
``` bash
|
|
43
|
+
$ docker run -p 6379:6379 -it redis/redis-stack:latest
|
|
38
44
|
```
|
|
39
45
|
|
|
40
46
|
To install redis-py, simply:
|
|
@@ -54,7 +60,7 @@ Looking for a high-level library to handle object mapping? See [redis-om-python]
|
|
|
54
60
|
|
|
55
61
|
## Supported Redis Versions
|
|
56
62
|
|
|
57
|
-
The most recent version of this library supports
|
|
63
|
+
The most recent version of this library supports Redis version [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES), [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES) and [8.0](https://github.com/redis/redis/blob/8.0/00-RELEASENOTES).
|
|
58
64
|
|
|
59
65
|
The table below highlights version compatibility of the most-recent library versions and redis versions.
|
|
60
66
|
|
|
@@ -155,8 +161,8 @@ The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs
|
|
|
155
161
|
|
|
156
162
|
### Redis’ search and query capabilities default dialect
|
|
157
163
|
|
|
158
|
-
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
|
|
159
|
-
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
|
|
164
|
+
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
|
|
165
|
+
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
|
|
160
166
|
|
|
161
167
|
**Important**: Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by configuring the client accordingly.
|
|
162
168
|
|
|
@@ -204,4 +210,4 @@ Special thanks to:
|
|
|
204
210
|
system.
|
|
205
211
|
- Paul Hubbard for initial packaging support.
|
|
206
212
|
|
|
207
|
-
[](https://redis.io)
|
|
213
|
+
[](https://redis.io)
|
|
@@ -16,11 +16,14 @@ from redis.exceptions import (
|
|
|
16
16
|
BusyLoadingError,
|
|
17
17
|
ChildDeadlockedError,
|
|
18
18
|
ConnectionError,
|
|
19
|
+
CrossSlotTransactionError,
|
|
19
20
|
DataError,
|
|
21
|
+
InvalidPipelineStack,
|
|
20
22
|
InvalidResponse,
|
|
21
23
|
OutOfMemoryError,
|
|
22
24
|
PubSubError,
|
|
23
25
|
ReadOnlyError,
|
|
26
|
+
RedisClusterException,
|
|
24
27
|
RedisError,
|
|
25
28
|
ResponseError,
|
|
26
29
|
TimeoutError,
|
|
@@ -42,7 +45,9 @@ def int_or_str(value):
|
|
|
42
45
|
return value
|
|
43
46
|
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
# This is the version of redis-py that is being used
|
|
49
|
+
# for building and installing the lib.
|
|
50
|
+
__version__ = "6.1.0"
|
|
46
51
|
VERSION = tuple(map(int_or_str, __version__.split(".")))
|
|
47
52
|
|
|
48
53
|
|
|
@@ -56,15 +61,18 @@ __all__ = [
|
|
|
56
61
|
"ConnectionError",
|
|
57
62
|
"ConnectionPool",
|
|
58
63
|
"CredentialProvider",
|
|
64
|
+
"CrossSlotTransactionError",
|
|
59
65
|
"DataError",
|
|
60
66
|
"from_url",
|
|
61
67
|
"default_backoff",
|
|
68
|
+
"InvalidPipelineStack",
|
|
62
69
|
"InvalidResponse",
|
|
63
70
|
"OutOfMemoryError",
|
|
64
71
|
"PubSubError",
|
|
65
72
|
"ReadOnlyError",
|
|
66
73
|
"Redis",
|
|
67
74
|
"RedisCluster",
|
|
75
|
+
"RedisClusterException",
|
|
68
76
|
"RedisError",
|
|
69
77
|
"ResponseError",
|
|
70
78
|
"Sentinel",
|
|
@@ -19,7 +19,7 @@ class _RESP3Parser(_RESPBase):
|
|
|
19
19
|
|
|
20
20
|
def handle_pubsub_push_response(self, response):
|
|
21
21
|
logger = getLogger("push_response")
|
|
22
|
-
logger.
|
|
22
|
+
logger.debug("Push response: " + str(response))
|
|
23
23
|
return response
|
|
24
24
|
|
|
25
25
|
def read_response(self, disable_decoding=False, push_request=False):
|
|
@@ -150,7 +150,7 @@ class _AsyncRESP3Parser(_AsyncRESPBase):
|
|
|
150
150
|
|
|
151
151
|
async def handle_pubsub_push_response(self, response):
|
|
152
152
|
logger = getLogger("push_response")
|
|
153
|
-
logger.
|
|
153
|
+
logger.debug("Push response: " + str(response))
|
|
154
154
|
return response
|
|
155
155
|
|
|
156
156
|
async def read_response(
|
|
@@ -39,6 +39,7 @@ from redis.asyncio.connection import (
|
|
|
39
39
|
)
|
|
40
40
|
from redis.asyncio.lock import Lock
|
|
41
41
|
from redis.asyncio.retry import Retry
|
|
42
|
+
from redis.backoff import ExponentialWithJitterBackoff
|
|
42
43
|
from redis.client import (
|
|
43
44
|
EMPTY_RESPONSE,
|
|
44
45
|
NEVER_DECODE,
|
|
@@ -65,7 +66,6 @@ from redis.exceptions import (
|
|
|
65
66
|
PubSubError,
|
|
66
67
|
RedisError,
|
|
67
68
|
ResponseError,
|
|
68
|
-
TimeoutError,
|
|
69
69
|
WatchError,
|
|
70
70
|
)
|
|
71
71
|
from redis.typing import ChannelT, EncodableT, KeyT
|
|
@@ -73,16 +73,19 @@ from redis.utils import (
|
|
|
73
73
|
HIREDIS_AVAILABLE,
|
|
74
74
|
SSL_AVAILABLE,
|
|
75
75
|
_set_info_logger,
|
|
76
|
+
deprecated_args,
|
|
76
77
|
deprecated_function,
|
|
77
78
|
get_lib_version,
|
|
78
79
|
safe_str,
|
|
79
80
|
str_if_bytes,
|
|
81
|
+
truncate_text,
|
|
80
82
|
)
|
|
81
83
|
|
|
82
84
|
if TYPE_CHECKING and SSL_AVAILABLE:
|
|
83
|
-
from ssl import TLSVersion
|
|
85
|
+
from ssl import TLSVersion, VerifyMode
|
|
84
86
|
else:
|
|
85
87
|
TLSVersion = None
|
|
88
|
+
VerifyMode = None
|
|
86
89
|
|
|
87
90
|
PubSubHandler = Callable[[Dict[str, str]], Awaitable[None]]
|
|
88
91
|
_KeyT = TypeVar("_KeyT", bound=KeyT)
|
|
@@ -206,6 +209,11 @@ class Redis(
|
|
|
206
209
|
client.auto_close_connection_pool = True
|
|
207
210
|
return client
|
|
208
211
|
|
|
212
|
+
@deprecated_args(
|
|
213
|
+
args_to_warn=["retry_on_timeout"],
|
|
214
|
+
reason="TimeoutError is included by default.",
|
|
215
|
+
version="6.0.0",
|
|
216
|
+
)
|
|
209
217
|
def __init__(
|
|
210
218
|
self,
|
|
211
219
|
*,
|
|
@@ -223,14 +231,17 @@ class Redis(
|
|
|
223
231
|
encoding_errors: str = "strict",
|
|
224
232
|
decode_responses: bool = False,
|
|
225
233
|
retry_on_timeout: bool = False,
|
|
234
|
+
retry: Retry = Retry(
|
|
235
|
+
backoff=ExponentialWithJitterBackoff(base=1, cap=10), retries=3
|
|
236
|
+
),
|
|
226
237
|
retry_on_error: Optional[list] = None,
|
|
227
238
|
ssl: bool = False,
|
|
228
239
|
ssl_keyfile: Optional[str] = None,
|
|
229
240
|
ssl_certfile: Optional[str] = None,
|
|
230
|
-
ssl_cert_reqs: str = "required",
|
|
241
|
+
ssl_cert_reqs: Union[str, VerifyMode] = "required",
|
|
231
242
|
ssl_ca_certs: Optional[str] = None,
|
|
232
243
|
ssl_ca_data: Optional[str] = None,
|
|
233
|
-
ssl_check_hostname: bool =
|
|
244
|
+
ssl_check_hostname: bool = True,
|
|
234
245
|
ssl_min_version: Optional[TLSVersion] = None,
|
|
235
246
|
ssl_ciphers: Optional[str] = None,
|
|
236
247
|
max_connections: Optional[int] = None,
|
|
@@ -240,7 +251,6 @@ class Redis(
|
|
|
240
251
|
lib_name: Optional[str] = "redis-py",
|
|
241
252
|
lib_version: Optional[str] = get_lib_version(),
|
|
242
253
|
username: Optional[str] = None,
|
|
243
|
-
retry: Optional[Retry] = None,
|
|
244
254
|
auto_close_connection_pool: Optional[bool] = None,
|
|
245
255
|
redis_connect_func=None,
|
|
246
256
|
credential_provider: Optional[CredentialProvider] = None,
|
|
@@ -249,10 +259,24 @@ class Redis(
|
|
|
249
259
|
):
|
|
250
260
|
"""
|
|
251
261
|
Initialize a new Redis client.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
262
|
+
|
|
263
|
+
To specify a retry policy for specific errors, you have two options:
|
|
264
|
+
|
|
265
|
+
1. Set the `retry_on_error` to a list of the error/s to retry on, and
|
|
266
|
+
you can also set `retry` to a valid `Retry` object(in case the default
|
|
267
|
+
one is not appropriate) - with this approach the retries will be triggered
|
|
268
|
+
on the default errors specified in the Retry object enriched with the
|
|
269
|
+
errors specified in `retry_on_error`.
|
|
270
|
+
|
|
271
|
+
2. Define a `Retry` object with configured 'supported_errors' and set
|
|
272
|
+
it to the `retry` parameter - with this approach you completely redefine
|
|
273
|
+
the errors on which retries will happen.
|
|
274
|
+
|
|
275
|
+
`retry_on_timeout` is deprecated - please include the TimeoutError
|
|
276
|
+
either in the Retry object or in the `retry_on_error` list.
|
|
277
|
+
|
|
278
|
+
When 'connection_pool' is provided - the retry configuration of the
|
|
279
|
+
provided pool will be used.
|
|
256
280
|
"""
|
|
257
281
|
kwargs: Dict[str, Any]
|
|
258
282
|
if event_dispatcher is None:
|
|
@@ -278,8 +302,6 @@ class Redis(
|
|
|
278
302
|
# Create internal connection pool, expected to be closed by Redis instance
|
|
279
303
|
if not retry_on_error:
|
|
280
304
|
retry_on_error = []
|
|
281
|
-
if retry_on_timeout is True:
|
|
282
|
-
retry_on_error.append(TimeoutError)
|
|
283
305
|
kwargs = {
|
|
284
306
|
"db": db,
|
|
285
307
|
"username": username,
|
|
@@ -289,7 +311,6 @@ class Redis(
|
|
|
289
311
|
"encoding": encoding,
|
|
290
312
|
"encoding_errors": encoding_errors,
|
|
291
313
|
"decode_responses": decode_responses,
|
|
292
|
-
"retry_on_timeout": retry_on_timeout,
|
|
293
314
|
"retry_on_error": retry_on_error,
|
|
294
315
|
"retry": copy.deepcopy(retry),
|
|
295
316
|
"max_connections": max_connections,
|
|
@@ -401,10 +422,10 @@ class Redis(
|
|
|
401
422
|
"""Get the connection's key-word arguments"""
|
|
402
423
|
return self.connection_pool.connection_kwargs
|
|
403
424
|
|
|
404
|
-
def get_retry(self) -> Optional[
|
|
425
|
+
def get_retry(self) -> Optional[Retry]:
|
|
405
426
|
return self.get_connection_kwargs().get("retry")
|
|
406
427
|
|
|
407
|
-
def set_retry(self, retry:
|
|
428
|
+
def set_retry(self, retry: Retry) -> None:
|
|
408
429
|
self.get_connection_kwargs().update({"retry": retry})
|
|
409
430
|
self.connection_pool.set_retry(retry)
|
|
410
431
|
|
|
@@ -631,18 +652,17 @@ class Redis(
|
|
|
631
652
|
await conn.send_command(*args)
|
|
632
653
|
return await self.parse_response(conn, command_name, **options)
|
|
633
654
|
|
|
634
|
-
async def
|
|
655
|
+
async def _close_connection(self, conn: Connection):
|
|
635
656
|
"""
|
|
636
|
-
Close the connection
|
|
637
|
-
|
|
638
|
-
|
|
657
|
+
Close the connection before retrying.
|
|
658
|
+
|
|
659
|
+
The supported exceptions are already checked in the
|
|
660
|
+
retry object so we don't need to do it here.
|
|
661
|
+
|
|
662
|
+
After we disconnect the connection, it will try to reconnect and
|
|
663
|
+
do a health check as part of the send_command logic(on connection level).
|
|
639
664
|
"""
|
|
640
665
|
await conn.disconnect()
|
|
641
|
-
if (
|
|
642
|
-
conn.retry_on_error is None
|
|
643
|
-
or isinstance(error, tuple(conn.retry_on_error)) is False
|
|
644
|
-
):
|
|
645
|
-
raise error
|
|
646
666
|
|
|
647
667
|
# COMMAND EXECUTION AND PROTOCOL PARSING
|
|
648
668
|
async def execute_command(self, *args, **options):
|
|
@@ -659,7 +679,7 @@ class Redis(
|
|
|
659
679
|
lambda: self._send_command_parse_response(
|
|
660
680
|
conn, command_name, *args, **options
|
|
661
681
|
),
|
|
662
|
-
lambda
|
|
682
|
+
lambda _: self._close_connection(conn),
|
|
663
683
|
)
|
|
664
684
|
finally:
|
|
665
685
|
if self.single_connection_client:
|
|
@@ -927,19 +947,11 @@ class PubSub:
|
|
|
927
947
|
)
|
|
928
948
|
)
|
|
929
949
|
|
|
930
|
-
async def
|
|
950
|
+
async def _reconnect(self, conn):
|
|
931
951
|
"""
|
|
932
|
-
|
|
933
|
-
if retry_on_error is not set or the error is not one
|
|
934
|
-
of the specified error types. Otherwise, try to
|
|
935
|
-
reconnect
|
|
952
|
+
Try to reconnect
|
|
936
953
|
"""
|
|
937
954
|
await conn.disconnect()
|
|
938
|
-
if (
|
|
939
|
-
conn.retry_on_error is None
|
|
940
|
-
or isinstance(error, tuple(conn.retry_on_error)) is False
|
|
941
|
-
):
|
|
942
|
-
raise error
|
|
943
955
|
await conn.connect()
|
|
944
956
|
|
|
945
957
|
async def _execute(self, conn, command, *args, **kwargs):
|
|
@@ -952,7 +964,7 @@ class PubSub:
|
|
|
952
964
|
"""
|
|
953
965
|
return await conn.retry.call_with_retry(
|
|
954
966
|
lambda: command(*args, **kwargs),
|
|
955
|
-
lambda
|
|
967
|
+
lambda _: self._reconnect(conn),
|
|
956
968
|
)
|
|
957
969
|
|
|
958
970
|
async def parse_response(self, block: bool = True, timeout: float = 0):
|
|
@@ -1243,7 +1255,8 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1243
1255
|
in one transmission. This is convenient for batch processing, such as
|
|
1244
1256
|
saving all the values in a list to Redis.
|
|
1245
1257
|
|
|
1246
|
-
All commands executed within a pipeline
|
|
1258
|
+
All commands executed within a pipeline(when running in transactional mode,
|
|
1259
|
+
which is the default behavior) are wrapped with MULTI and EXEC
|
|
1247
1260
|
calls. This guarantees all commands executed in the pipeline will be
|
|
1248
1261
|
executed atomically.
|
|
1249
1262
|
|
|
@@ -1272,7 +1285,7 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1272
1285
|
self.shard_hint = shard_hint
|
|
1273
1286
|
self.watching = False
|
|
1274
1287
|
self.command_stack: CommandStackT = []
|
|
1275
|
-
self.scripts: Set[
|
|
1288
|
+
self.scripts: Set[Script] = set()
|
|
1276
1289
|
self.explicit_transaction = False
|
|
1277
1290
|
|
|
1278
1291
|
async def __aenter__(self: _RedisT) -> _RedisT:
|
|
@@ -1344,36 +1357,36 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1344
1357
|
return self.immediate_execute_command(*args, **kwargs)
|
|
1345
1358
|
return self.pipeline_execute_command(*args, **kwargs)
|
|
1346
1359
|
|
|
1347
|
-
async def
|
|
1360
|
+
async def _disconnect_reset_raise_on_watching(
|
|
1361
|
+
self,
|
|
1362
|
+
conn: Connection,
|
|
1363
|
+
error: Exception,
|
|
1364
|
+
):
|
|
1348
1365
|
"""
|
|
1349
|
-
Close the connection
|
|
1350
|
-
raise an exception if we were watching
|
|
1351
|
-
|
|
1352
|
-
|
|
1366
|
+
Close the connection reset watching state and
|
|
1367
|
+
raise an exception if we were watching.
|
|
1368
|
+
|
|
1369
|
+
The supported exceptions are already checked in the
|
|
1370
|
+
retry object so we don't need to do it here.
|
|
1371
|
+
|
|
1372
|
+
After we disconnect the connection, it will try to reconnect and
|
|
1373
|
+
do a health check as part of the send_command logic(on connection level).
|
|
1353
1374
|
"""
|
|
1354
1375
|
await conn.disconnect()
|
|
1355
1376
|
# if we were already watching a variable, the watch is no longer
|
|
1356
1377
|
# valid since this connection has died. raise a WatchError, which
|
|
1357
1378
|
# indicates the user should retry this transaction.
|
|
1358
1379
|
if self.watching:
|
|
1359
|
-
await self.
|
|
1380
|
+
await self.reset()
|
|
1360
1381
|
raise WatchError(
|
|
1361
|
-
"A
|
|
1382
|
+
f"A {type(error).__name__} occurred while watching one or more keys"
|
|
1362
1383
|
)
|
|
1363
|
-
# if retry_on_error is not set or the error is not one
|
|
1364
|
-
# of the specified error types, raise it
|
|
1365
|
-
if (
|
|
1366
|
-
conn.retry_on_error is None
|
|
1367
|
-
or isinstance(error, tuple(conn.retry_on_error)) is False
|
|
1368
|
-
):
|
|
1369
|
-
await self.aclose()
|
|
1370
|
-
raise
|
|
1371
1384
|
|
|
1372
1385
|
async def immediate_execute_command(self, *args, **options):
|
|
1373
1386
|
"""
|
|
1374
|
-
Execute a command immediately, but don't auto-retry on
|
|
1375
|
-
|
|
1376
|
-
issuing WATCH or subsequent commands retrieving their values but before
|
|
1387
|
+
Execute a command immediately, but don't auto-retry on the supported
|
|
1388
|
+
errors for retry if we're already WATCHing a variable.
|
|
1389
|
+
Used when issuing WATCH or subsequent commands retrieving their values but before
|
|
1377
1390
|
MULTI is called.
|
|
1378
1391
|
"""
|
|
1379
1392
|
command_name = args[0]
|
|
@@ -1387,7 +1400,7 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1387
1400
|
lambda: self._send_command_parse_response(
|
|
1388
1401
|
conn, command_name, *args, **options
|
|
1389
1402
|
),
|
|
1390
|
-
lambda error: self.
|
|
1403
|
+
lambda error: self._disconnect_reset_raise_on_watching(conn, error),
|
|
1391
1404
|
)
|
|
1392
1405
|
|
|
1393
1406
|
def pipeline_execute_command(self, *args, **options):
|
|
@@ -1513,7 +1526,10 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1513
1526
|
self, exception: Exception, number: int, command: Iterable[object]
|
|
1514
1527
|
) -> None:
|
|
1515
1528
|
cmd = " ".join(map(safe_str, command))
|
|
1516
|
-
msg =
|
|
1529
|
+
msg = (
|
|
1530
|
+
f"Command # {number} ({truncate_text(cmd)}) "
|
|
1531
|
+
"of pipeline caused error: {exception.args}"
|
|
1532
|
+
)
|
|
1517
1533
|
exception.args = (msg,) + exception.args[1:]
|
|
1518
1534
|
|
|
1519
1535
|
async def parse_response(
|
|
@@ -1539,11 +1555,15 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1539
1555
|
if not exist:
|
|
1540
1556
|
s.sha = await immediate("SCRIPT LOAD", s.script)
|
|
1541
1557
|
|
|
1542
|
-
async def
|
|
1558
|
+
async def _disconnect_raise_on_watching(self, conn: Connection, error: Exception):
|
|
1543
1559
|
"""
|
|
1544
|
-
Close the connection, raise an exception if we were watching
|
|
1545
|
-
|
|
1546
|
-
|
|
1560
|
+
Close the connection, raise an exception if we were watching.
|
|
1561
|
+
|
|
1562
|
+
The supported exceptions are already checked in the
|
|
1563
|
+
retry object so we don't need to do it here.
|
|
1564
|
+
|
|
1565
|
+
After we disconnect the connection, it will try to reconnect and
|
|
1566
|
+
do a health check as part of the send_command logic(on connection level).
|
|
1547
1567
|
"""
|
|
1548
1568
|
await conn.disconnect()
|
|
1549
1569
|
# if we were watching a variable, the watch is no longer valid
|
|
@@ -1551,16 +1571,8 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1551
1571
|
# indicates the user should retry this transaction.
|
|
1552
1572
|
if self.watching:
|
|
1553
1573
|
raise WatchError(
|
|
1554
|
-
"A
|
|
1574
|
+
f"A {type(error).__name__} occurred while watching one or more keys"
|
|
1555
1575
|
)
|
|
1556
|
-
# if retry_on_error is not set or the error is not one
|
|
1557
|
-
# of the specified error types, raise it
|
|
1558
|
-
if (
|
|
1559
|
-
conn.retry_on_error is None
|
|
1560
|
-
or isinstance(error, tuple(conn.retry_on_error)) is False
|
|
1561
|
-
):
|
|
1562
|
-
await self.reset()
|
|
1563
|
-
raise
|
|
1564
1576
|
|
|
1565
1577
|
async def execute(self, raise_on_error: bool = True) -> List[Any]:
|
|
1566
1578
|
"""Execute all the commands in the current pipeline"""
|
|
@@ -1585,7 +1597,7 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
|
|
|
1585
1597
|
try:
|
|
1586
1598
|
return await conn.retry.call_with_retry(
|
|
1587
1599
|
lambda: execute(conn, stack, raise_on_error),
|
|
1588
|
-
lambda error: self.
|
|
1600
|
+
lambda error: self._disconnect_raise_on_watching(conn, error),
|
|
1589
1601
|
)
|
|
1590
1602
|
finally:
|
|
1591
1603
|
await self.reset()
|