summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Malinovskiy <u.glide@gmail.com>2023-02-07 12:06:35 +0200
committerGitHub <noreply@github.com>2023-02-07 12:06:35 +0200
commitfcd8f98509c5c7c14ee5a3201b56b8bf755a4b7c (patch)
treeedfef678791718a9feb2c868a7e4fefb3183fc6c
parente7306aae64b728fc6d894faed046960de76710c4 (diff)
downloadredis-py-fcd8f98509c5c7c14ee5a3201b56b8bf755a4b7c.tar.gz
Add TS.MGET example for OS Redis Cluster (#2507)
-rw-r--r--docs/examples/timeseries_examples.ipynb41
1 files changed, 41 insertions, 0 deletions
diff --git a/docs/examples/timeseries_examples.ipynb b/docs/examples/timeseries_examples.ipynb
index fefc0c8..691e133 100644
--- a/docs/examples/timeseries_examples.ipynb
+++ b/docs/examples/timeseries_examples.ipynb
@@ -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": {