TSRANGEBYTIME
This page documents the preview (v2.21) version. Preview includes features under active development and is for development and testing only. For production, use the stable (v2024.1) version.
Synopsis
TSRANGEBYTIME key low_ts high_ts
This command fetches the values for the given low_ts, high_ts range in the time series that is
specified by the given key.
- If the given
keyis associated with non-time series data, an error is raised. - If the given
low_tsorhigh_tsare not a valid signed 64 bit integers, an error is raised. low_tsandhigh_tsare inclusive unless they are prefixed with(, in that case they are exclusive.- Special bounds
-infand+infare also supported to retrieve an entire range
Return value
Returns a list of timestamp, value pairs found in the range specified by low_ts, high_ts.
Examples
You can do this as shown below.
TSADD ts 1 one 2 two 3 three 4 four 5 five 6 six
"OK"
TSRANGEBYTIME ts_key 2 4
1) "2"
2) "two"
3) "3"
4) "three"
5) "4"
6) "four"
2 is exclusive
TSRANGEBYTIME ts_key (2 4
1) "3"
2) "three"
3) "4"
4) "four"
2 and 4 are exclusive
TSRANGEBYTIME ts_key (2 (4
1) "3"
2) "three"
TSRANGEBYTIME ts_key -inf 3
1) "1"
2) "one"
3) "2"
4) "two"
5) "3"
6) "three"
TSRANGEBYTIME ts_key 2 +inf
1) "2"
2) "two"
3) "3"
4) "three"
5) "4"
6) "four"
7) "5"
8) "five"
9) "6"
10) "six"