9951 explained code solutions for 126 technologies


redis-timeseriesPython Redis time series example


This examples is based on Redis Timeseries module:

r = redis.Redis()
list = r.eval("return redis.call('TS.RANGE', 'ts_2', 1644415000020, 1644417094099)", 0)ctrl + c
redis.Redis

connect to Redis server

eval

executes Lua script

redis.call

calls RAW Redis command

TS.RANGE

RedisTimeSeries command to get time series range

ts_2

name of the time series object

1644415000020

start timestamp (in microseconds)

1644417094099

end timestamp (in microseconds)


Usage example

import redis

r = redis.Redis()
list = r.eval("return redis.call('TS.RANGE', 'ts_2', 1644415000020, 1644417094099)", 0)
print(list)
output
[[1644416919386, b'12'], [1644416925338, b'14'], [1644417094095, b'15']]