Redis Timeseries mget无法获取标签

eoigrqb6  于 9个月前  发布在  Redis
关注(0)|答案(1)|浏览(69)

我正在尝试将标记数据添加到Redis时间序列。我使用Python添加数据,但尝试使用mget获取数据并没有得到任何东西。我得到的只是一个空列表:

import redis

rd = redis.StrictRedis(host='localhost', port=6379, decode_responses=True)
rd.flushall()

ts = rd.ts() # The timeseries object
ts.create("foo", retention_msecs=90*24*60*60*1000) # 90 days expiration
ts.add("foo", 1, 100, labels={"org": "Apple", "suborg": "Engineering"})
result = ts.mget([f"org=Apple"], with_labels=True)
print(result)

结果如下:

[]

我希望打印的结果不是一个空列表。

  • 这是一个bug,还是我做错了什么?*

作为参考,一些Redis Timeseries for Python的文档:https://redis-py.readthedocs.io/en/stable/redismodules.html#redis.commands.json.commands.JSONCommands.mget
还有一些关于如何使用python的redis timeseries的一般指南:https://redis-py.readthedocs.io/en/stable/examples/timeseries_examples.html

7hiiyaii

7hiiyaii1#

只有在密钥之前不存在的情况下,才会使用ts.add和ts.madd中的创建参数。
因为“foo”已经由ts.create创建,所以创建参数被忽略。
您可以按如下方式将标签添加到create命令中:ts.create(“foo”,retention_msecs=902460601000,labels={“org”:“Apple”,“suborg”:“工程”})# 90天有效期

相关问题