Add TS.MGET example for OS Redis Cluster
"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": {
