Skip to content

Commit fcd8f98

Browse files
authored
Add TS.MGET example for OS Redis Cluster (#2507)
1 parent e7306aa commit fcd8f98

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

docs/examples/timeseries_examples.ipynb

+41
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,47 @@
599599
"source": [
600600
"ts.range(\"ts_key_incr\", \"-\", \"+\")"
601601
]
602+
},
603+
{
604+
"cell_type": "markdown",
605+
"source": [
606+
"## How to execute multi-key commands on Open Source Redis Cluster"
607+
],
608+
"metadata": {
609+
"collapsed": false
610+
}
611+
},
612+
{
613+
"cell_type": "code",
614+
"execution_count": 4,
615+
"outputs": [
616+
{
617+
"data": {
618+
"text/plain": "[{'ts_key1': [{}, 1670927124746, 2.0]}, {'ts_key2': [{}, 1670927124748, 10.0]}]"
619+
},
620+
"execution_count": 4,
621+
"metadata": {},
622+
"output_type": "execute_result"
623+
}
624+
],
625+
"source": [
626+
"import redis\n",
627+
"\n",
628+
"r = redis.RedisCluster(host=\"localhost\", port=46379)\n",
629+
"\n",
630+
"# This command should be executed on all cluster nodes after creation and any re-sharding\n",
631+
"# Please note that this command is internal and will be deprecated in the future\n",
632+
"r.execute_command(\"timeseries.REFRESHCLUSTER\", target_nodes=\"primaries\")\n",
633+
"\n",
634+
"# Now multi-key commands can be executed\n",
635+
"ts = r.ts()\n",
636+
"ts.add(\"ts_key1\", \"*\", 2, labels={\"label1\": 1, \"label2\": 2})\n",
637+
"ts.add(\"ts_key2\", \"*\", 10, labels={\"label1\": 1, \"label2\": 2})\n",
638+
"ts.mget([\"label1=1\"])"
639+
],
640+
"metadata": {
641+
"collapsed": false
642+
}
602643
}
603644
],
604645
"metadata": {

0 commit comments

Comments
 (0)