TSLASTN
AttentionThis page documents an earlier version. Go to the latest (v2.1)version.
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.
- If the given
key
is associated with non-timeseries data, an error is raised. - If the given
N
is not a positive 32 bit integer, an error is raised.
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
See Also
当前内容版权归 YugabyteDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 YugabyteDB .