TS.GET key 
Available in:
Redis Stack / TimeSeries 1.0.0
Time complexity:

Get the last sample


Required arguments


is key name for the time series.

Optional arguments

LATEST (since RedisTimeSeries v1.8)

is used when a time series is a compaction. With LATEST, TS.MRANGE also reports the compacted value of the latest possibly partial bucket, given that this bucket's start time falls within [fromTimestamp, toTimestamp]. Without LATEST, TS.MRANGE does not report the latest possibly partial bucket. When a time series is not a compaction, LATEST is ignored.

The data in the latest bucket of a compaction is possibly partial. A bucket is closed and compacted only upon arrival of a new sample that opens a new latest bucket. There are cases, however, when the compacted value of the latest possibly partial bucket is also required. In such a case, use LATEST.

Return value

The returned array contains:

  • The last sample timestamp, followed by the last sample value, when the time series contains data.
  • An empty array, when the time series is empty.


Get last temperature sample for a city

Create time series for temperature in Tel Aviv and Jerusalem, then add different temperature samples.> TS.CREATE temp:TLV LABELS type temp location TLV
OK> TS.CREATE temp:JLM LABELS type temp location JLM
OK> TS.MADD temp:TLV 1000 30 temp:TLV 1010 35 temp:TLV 1020 9999 temp:TLV 1030 40
1) (integer) 1000
2) (integer) 1010
3) (integer) 1020
4) (integer) 1030> TS.MADD temp:JLM 1005 30 temp:JLM 1015 35 temp:JLM 1025 9999 temp:JLM 1035 40
1) (integer) 1005
2) (integer) 1015
3) (integer) 1025
4) (integer) 1035

Get the last timestamp and temperature value for Jerusalem.> TS.GET temp:JLM
1) (integer) 1035
2) 40>

See also




If you've found issues on this page, or have suggestions for improvement, please submit a request to merge or open an issue in the repository.