TSREVRANGEBYTIME

AttentionThis page documents an earlier version. Go to the latest (v2.1)version.

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 isspecified by the given key ordered from newest to oldest. If LIMIT is specified, then at mostlimit pairs will be fetched.

  • If the given key is associated with non-timeseries data, an error is raised.
  • If the given low_ts or high_ts are not a valid signed 64 bit integers, an error is raised.
  • If limit is not a valid positive 32 bit integer, an error is raised.
  • low_ts and high_ts are inclusive unless they are prefixed with (, in that case they areexclusive.
  • Special bounds -inf and +inf are 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. IfLIMIT is specified, at most limit pairs will be fetched.

Examples

You can do this as shown below.

  1. TSADD ts_key 1 one 2 two 3 three 4 four 5 five 6 six
  1. "OK"
  1. TSREVRANGEBYTIME ts_key 2 4
  1. 1) "4"
  2. 2) "four"
  3. 3) "3"
  4. 4) "three"
  5. 5) "2"
  6. 6) "two"

2 is exclusive

  1. TSREVRANGEBYTIME ts_key (2 4
  1. 1) "4"
  2. 2) "four"
  3. 3) "3"
  4. 4) "three"

2 and 4 are exclusive

  1. TSREVRANGEBYTIME ts_key (2 (4
  1. 1) "3"
  2. 2) "three"
  1. TSREVRANGEBYTIME ts_key -inf 3
  1. 1) "3"
  2. 2) "three"
  3. 3) "2"
  4. 4) "two"
  5. 5) "1"
  6. 6) "one"
  1. TSREVRANGEBYTIME ts_key 2 +inf
  1. 1) "6"
  2. 2) "six"
  3. 3) "5"
  4. 4) "five"
  5. 5) "4"
  6. 6) "four"
  7. 7) "3"
  8. 8) "three"
  9. 9) "2"
  10. 10) "two"
  1. TSREVRANGEBYTIME ts_key -inf 3 LIMIT 2
  1. 1) "3"
  2. 2) "three"
  3. 3) "2"
  4. 4) "two"
  1. TSREVRANGEBYTIME ts_key -inf 3 LIMIT 10
  1. 1) "3"
  2. 2) "three"
  3. 3) "2"
  4. 4) "two"
  5. 5) "1"
  6. 6) "one"

See Also

tsrangebytime, tsadd, tsget,tsrem, tslastn, tscard