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
Copy file name to clipboardExpand all lines: README.md
+11-1Lines changed: 11 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,8 @@ The table below higlights version compatibility of the most-recent library versi
45
45
| Library version | Supported redis versions |
46
46
|-----------------|-------------------|
47
47
| 3.5.3 | <= 6.2 Family of releases |
48
-
| >= 4.1.0 | Version 5.0 to current |
48
+
| >= 4.5.0 | Version 5.0 to 7.0 |
49
+
| >= 5.0.0 | Versiond 5.0 to current |
49
50
50
51
51
52
## Usage
@@ -63,6 +64,15 @@ b'bar'
63
64
64
65
The above code connects to localhost on port 6379, sets a value in Redis, and retrieves it. All responses are returned as bytes in Python, to receive decoded strings, set *decode_responses=True*. For this, and more connection options, see [these examples](https://redis.readthedocs.io/en/stable/examples.html).
65
66
67
+
68
+
#### RESP3 Support
69
+
To enable support for RESP3, ensure you have at least version 5.0 of the client, and change your connection object to include *protocol=3*
70
+
71
+
```python
72
+
>>>import redis
73
+
>>> r = redis.Redis(host='localhost', port=6379, db=0, protocol=3)
74
+
```
75
+
66
76
### Connection Pools
67
77
68
78
By default, redis-py uses a connection pool to manage connections. Each instance of a Redis class receives its own connection pool. You can however define your own [redis.ConnectionPool](https://redis.readthedocs.io/en/stable/connections.html#connection-pools).
"If you supply a custom `ConnectionPool` that is supplied to several `Redis` instances, you may want to disconnect the connection pool explicitly. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
51
-
],
52
49
"metadata": {
53
50
"collapsed": false,
54
51
"pycharm": {
55
52
"name": "#%% md\n"
56
53
}
57
-
}
54
+
},
55
+
"source": [
56
+
"If you supply a custom `ConnectionPool` that is supplied to several `Redis` instances, you may want to disconnect the connection pool explicitly. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
"By default, this library uses version 2 of the RESP protocol. To enable RESP version 3, you will want to set `protocol` to 3"
83
+
]
84
+
},
85
+
{
86
+
"cell_type": "code",
87
+
"execution_count": null,
88
+
"metadata": {},
89
+
"outputs": [],
90
+
"source": [
91
+
"import redis.asyncio as redis\n",
92
+
"\n",
93
+
"connection = redis.Redis(protocol=3)\n",
94
+
"await connection.close()\n",
95
+
"await connection.ping()"
96
+
]
97
+
},
98
+
{
99
+
"cell_type": "markdown",
71
100
"metadata": {
72
101
"collapsed": false,
73
102
"pycharm": {
74
-
"name": "#%%\n"
103
+
"name": "#%% md\n"
75
104
}
76
-
}
77
-
},
78
-
{
79
-
"cell_type": "markdown",
105
+
},
80
106
"source": [
81
107
"## Transactions (Multi/Exec)\n",
82
108
"\n",
@@ -85,17 +111,17 @@
85
111
"The commands will not be reflected in Redis until execute() is called & awaited.\n",
86
112
"\n",
87
113
"Usually, when performing a bulk operation, taking advantage of a “transaction” (e.g., Multi/Exec) is to be desired, as it will also add a layer of atomicity to your bulk operation."
"Subscribing to channels matching a glob-style pattern:"
185
-
],
186
203
"metadata": {
187
204
"collapsed": false,
188
205
"pycharm": {
189
206
"name": "#%% md\n"
190
207
}
191
-
}
208
+
},
209
+
"source": [
210
+
"Subscribing to channels matching a glob-style pattern:"
211
+
]
192
212
},
193
213
{
194
214
"cell_type": "code",
195
215
"execution_count": 5,
216
+
"metadata": {
217
+
"collapsed": false,
218
+
"pycharm": {
219
+
"name": "#%%\n"
220
+
}
221
+
},
196
222
"outputs": [
197
223
{
198
224
"name": "stdout",
@@ -234,16 +260,16 @@
234
260
" await r.publish(\"channel:1\", STOPWORD)\n",
235
261
"\n",
236
262
" await future"
237
-
],
263
+
]
264
+
},
265
+
{
266
+
"cell_type": "markdown",
238
267
"metadata": {
239
268
"collapsed": false,
240
269
"pycharm": {
241
-
"name": "#%%\n"
270
+
"name": "#%% md\n"
242
271
}
243
-
}
244
-
},
245
-
{
246
-
"cell_type": "markdown",
272
+
},
247
273
"source": [
248
274
"## Sentinel Client\n",
249
275
"\n",
@@ -252,17 +278,17 @@
252
278
"Calling aioredis.sentinel.Sentinel.master_for or aioredis.sentinel.Sentinel.slave_for methods will return Redis clients connected to specified services monitored by Sentinel.\n",
253
279
"\n",
254
280
"Sentinel client will detect failover and reconnect Redis clients automatically."
255
-
],
256
-
"metadata": {
257
-
"collapsed": false,
258
-
"pycharm": {
259
-
"name": "#%% md\n"
260
-
}
261
-
}
281
+
]
262
282
},
263
283
{
264
284
"cell_type": "code",
265
285
"execution_count": null,
286
+
"metadata": {
287
+
"collapsed": false,
288
+
"pycharm": {
289
+
"name": "#%%\n"
290
+
}
291
+
},
266
292
"outputs": [],
267
293
"source": [
268
294
"import asyncio\n",
@@ -277,13 +303,61 @@
277
303
"assert ok\n",
278
304
"val = await r.get(\"key\")\n",
279
305
"assert val == b\"value\""
280
-
],
281
-
"metadata": {
282
-
"collapsed": false,
283
-
"pycharm": {
284
-
"name": "#%%\n"
306
+
]
307
+
},
308
+
{
309
+
"cell_type": "markdown",
310
+
"metadata": {},
311
+
"source": [
312
+
"## Connecting to Redis instances by specifying a URL scheme.\n",
313
+
"Parameters are passed to the following schems, as parameters to the url scheme.\n",
314
+
"\n",
315
+
"Three URL schemes are supported:\n",
316
+
"\n",
317
+
"- `redis://` creates a TCP socket connection. <https://www.iana.org/assignments/uri-schemes/prov/redis>\n",
318
+
"- `rediss://` creates a SSL wrapped TCP socket connection. <https://www.iana.org/assignments/uri-schemes/prov/rediss>\n",
319
+
"- ``unix://``: creates a Unix Domain Socket connection.\n"
0 commit comments