TSLASTN
Synopsis
TSLASTN key N
This command fetches the latest N entries in the time series that is specified by the given key
.
The elements are returned in ascending order of timestamps.
Return value
Returns a list of timestamp, value pairs for the latest N entries in the time series.
Examples
You can do this as shown below.
$ TSADD ts_key 10 v1 20 v2 30 v3 40 v4 50 v5
"OK"
$ TSLASTN ts_key 2
1) "40"
2) "v4"
3) "50"
4) "v5"
$ TSLASTN ts_key 3
1) "30"
2) "v3"
3) "40"
4) "v4"
5) "50"
6) "v5"
$ TSLASTN ts_key 9999999999
(error) ERR tslastn: limit field 9999999999 is not within valid bounds
$ TSLASTN ts_key 0
(error) ERR tslastn: limit field 0 is not within valid bounds
$ TSLASTN ts_key -1
(error) ERR tslastn: limit field -1 is not within valid bounds