Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

TS.RANGE

Last updated
TS.RANGE key from to [COUNT count]
Group
Time series
Complexity
O(log N + M), M being the samples returned
Arity
-4 (at least 4 words, counting the command name)
Flags
read-only, slow
Keys
first 1, last 1, step 1
HotKV Cloud
Performance and Scale
On-Premise
requires the time-series license feature

TS.RANGE returns the samples of the time series key with timestamps from from to to, both included, oldest first.

Argument Meaning
from Start, in Unix milliseconds. - means the earliest.
to End, in Unix milliseconds. + means the latest.
COUNT count Return at most count samples, from the start of the range. 0 means no limit.

Other arguments after to are ignored.

An array of samples, each a two-element array: the timestamp (integer) and the value (bulk string with six decimals). The shape is the same in RESP2 and RESP3. A series that does not exist gives an empty array.

Error replies: ERR invalid from timestamp, ERR invalid to timestamp, ERR invalid COUNT, and NOLICENSE ... without the time-series license feature.

127.0.0.1:6379> TS.CREATE temp:kitchen
OK
127.0.0.1:6379> TS.ADD temp:kitchen 1700000000000 21.5
(integer) 1700000000000
127.0.0.1:6379> TS.ADD temp:kitchen 1700000060000 21.75
(integer) 1700000060000
127.0.0.1:6379> TS.ADD temp:kitchen 1700000120000 22
(integer) 1700000120000
127.0.0.1:6379> TS.RANGE temp:kitchen - + COUNT 2
1) 1) (integer) 1700000000000
2) "21.500000"
2) 1) (integer) 1700000060000
2) "21.750000"
127.0.0.1:6379> TS.RANGE temp:kitchen 1700000100000 +
1) 1) (integer) 1700000120000
2) "22.000000"

HotKV’s own time series API. TS.RANGE shares its name with the RedisTimeSeries command but takes only COUNT; use TS.AGG for aggregation. Values are returned with six decimals.

TS.AGG, TS.ADD, TS.INFO