我正在尝试使用Python redistimeseries包(RedisLabs v0.8.0) Python Redis包(RedisLabs)v3.5.3
但是,当我执行TS.ADD时,它总是返回错误
redis.exceptions.ResponseError: TSDB: Timestamp cannot be older than the latest timestamp in the time series
不管我给它什么时间戳。我可以使用相同的时间戳值,在相同的时间序列上执行相同的插件redis cli,而不会出现任何问题
为了确保现有记录不是问题所在,我创建了一个新的时间序列,因此不存在键/值/时间戳。同样的结果
例如:
REDIS-CLI 127.0.0.1:6379> TS.CREATE FAN02.RUNTIME RETENTION 604800 LABELS eq_type FANS location SITE1
REDIS-CLI 127.0.0.1:6379> TS.ADD FAN04.RUNTIME 1591720015 39
(integer) 1591720015
很好
但是如果我在Python中也这样做(使用一个新的空时间序列),使用当前的时间戳就会得到错误
>>> int(time.time())
1591720015
import redistimeseries.client
rts = redistimeseries.client.Client(host='x.x.x.x', port=6379)
rts.add('FAN04.RUNTIME', int(time.time()), newval)
>>> stacktrace
File "C:/.../putdata.py", line 105, in main
rts.add('FAN04.RUNTIME', int(time.time()), newval)
File "C:\...\venv\lib\site-packages\redistimeseries\client.py", line 186, in add
return self.execute_command(self.ADD_CMD, *params)
File "C:\...\venv\lib\site-packages\redis\client.py", line 901, in execute_command
return self.parse_response(conn, command_name, **options)
File "C:\...\venv\lib\site-packages\redis\client.py", line 915, in parse_response
response = connection.read_response()
File "C:\...\venv\lib\site-packages\redis\connection.py", line 756, in read_response
raise response
redis.exceptions.ResponseError: TSDB: Timestamp cannot be older than the latest timestamp in the time series
我不知道发生了什么或者我做了什么不正确,我很难找到Python包的文档或示例,这些文档或示例会突出我的错误或缺乏理解
有什么想法吗
我使用的是Python 3.7、Redis 3.5.3、Redis TimeSeries 0.8.0
Python的
time.time()
将当前时间作为秒的浮点值返回,而RedisTimeSeries要求毫秒分辨率。。。尝试:或者使用
datetime
的now()
或类似的相关问题 更多 >
编程相关推荐