Skip to content

Commit

Permalink
Add TS.MGET example for OS Redis Cluster (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed Feb 7, 2023
1 parent e7306aa commit fcd8f98
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/examples/timeseries_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,47 @@
"source": [
"ts.range(\"ts_key_incr\", \"-\", \"+\")"
]
},
{
"cell_type": "markdown",
"source": [
"## How to execute multi-key commands on Open Source Redis Cluster"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 4,
"outputs": [
{
"data": {
"text/plain": "[{'ts_key1': [{}, 1670927124746, 2.0]}, {'ts_key2': [{}, 1670927124748, 10.0]}]"
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import redis\n",
"\n",
"r = redis.RedisCluster(host=\"localhost\", port=46379)\n",
"\n",
"# This command should be executed on all cluster nodes after creation and any re-sharding\n",
"# Please note that this command is internal and will be deprecated in the future\n",
"r.execute_command(\"timeseries.REFRESHCLUSTER\", target_nodes=\"primaries\")\n",
"\n",
"# Now multi-key commands can be executed\n",
"ts = r.ts()\n",
"ts.add(\"ts_key1\", \"*\", 2, labels={\"label1\": 1, \"label2\": 2})\n",
"ts.add(\"ts_key2\", \"*\", 10, labels={\"label1\": 1, \"label2\": 2})\n",
"ts.mget([\"label1=1\"])"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
Expand Down

0 comments on commit fcd8f98

Please sign in to comment.