We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 01c76e8 commit fa5c4acCopy full SHA for fa5c4ac
docs/examples/test.py
@@ -0,0 +1,27 @@
1
+import redis.asyncio as redis
2
+import asyncio
3
+from redis.commands.json.path import Path as Jsonpath
4
+
5
+host = "127.0.0.1"
6
+port = 46379
7
+tls = False
8
+ttl = 300
9
10
11
+async def main():
12
+ r = await redis.RedisCluster(host=host, port=port)
13
+ print(f"ping: {await r.ping()}")
14
15
+ async with r.pipeline() as pipe:
16
+ set_json, set_expire = await (
17
+ pipe
18
+ .json().set('test:test6', Jsonpath.root_path(), {'test': 'works'}, nx=True) # nx: if key not exists
19
+ .expire('test:test6', ttl)
20
+ .execute()
21
+ )
22
+ assert set_json, "setting key failed"
23
+ assert set_expire, "setting expire failed"
24
+ print(f"get result: {await r.json().get('test:test6')}")
25
+ await r.close()
26
27
+asyncio.run(main())
0 commit comments