TSREVRANGEBYTIME
Synopsis
TSREVRANGEBYTIME key low_ts high_ts [LIMIT limit]
This command fetches the values for the given low_ts
, high_ts
range in the time series that is
specified by the given key
ordered from newest to oldest. If LIMIT
is specified, then at most
limit
pairs will be fetched.
Return value
Returns a list of timestamp, value pairs found in the range specified by low_ts
, high_ts
. If
LIMIT
is specified, at most limit
pairs will be fetched.
Examples
You can do this as shown below.
TSADD ts_key 1 one 2 two 3 three 4 four 5 five 6 six
"OK"
TSREVRANGEBYTIME ts_key 2 4
1) "4"
2) "four"
3) "3"
4) "three"
5) "2"
6) "two"
2 is exclusive
TSREVRANGEBYTIME ts_key (2 4
1) "4"
2) "four"
3) "3"
4) "three"
2 and 4 are exclusive
TSREVRANGEBYTIME ts_key (2 (4
1) "3"
2) "three"
TSREVRANGEBYTIME ts_key -inf 3
1) "3"
2) "three"
3) "2"
4) "two"
5) "1"
6) "one"
TSREVRANGEBYTIME ts_key 2 +inf
1) "6"
2) "six"
3) "5"
4) "five"
5) "4"
6) "four"
7) "3"
8) "three"
9) "2"
10) "two"
TSREVRANGEBYTIME ts_key -inf 3 LIMIT 2
1) "3"
2) "three"
3) "2"
4) "two"
TSREVRANGEBYTIME ts_key -inf 3 LIMIT 10
1) "3"
2) "three"
3) "2"
4) "two"
5) "1"
6) "one"