TS.RANGE
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.
Arguments and options
Section titled “Arguments and options”| 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.
Return value
Section titled “Return value”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.
Examples
Section titled “Examples”127.0.0.1:6379> TS.CREATE temp:kitchenOK127.0.0.1:6379> TS.ADD temp:kitchen 1700000000000 21.5(integer) 1700000000000127.0.0.1:6379> TS.ADD temp:kitchen 1700000060000 21.75(integer) 1700000060000127.0.0.1:6379> TS.ADD temp:kitchen 1700000120000 22(integer) 1700000120000127.0.0.1:6379> TS.RANGE temp:kitchen - + COUNT 21) 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"Compatibility
Section titled “Compatibility”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.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.