TS.CREATE
TS.CREATE key [RETENTION milliseconds] [LABELS label value [label value ...]]
- Group
- Time series
- Complexity
- O(L), L being the labels
- Arity
- -2 (at least 2 words, counting the command name)
- Flags
- write, slow
- Keys
- first 1, last 1, step 1
- HotKV Cloud
- Performance and Scale
- On-Premise
- requires the time-series license feature
TS.CREATE creates an empty time series named key. A time series holds
samples (a millisecond timestamp and a floating-point value) in time order.
Add samples with TS.ADD, read them with
TS.RANGE and summarize them with
TS.AGG.
Time series live beside the keyspace: KEYS, EXISTS and DEL do not see them, and a series name does not clash with a key of the same name. They are kept in snapshots. In cluster mode, a series lives on the node that owns the hash slot of its name.
Time series need the time-series license feature on HotKV On-Premise, and
are included in the Performance and Scale plans on HotKV Cloud. Without it,
every TS.* command replies
NOLICENSE time-series requires a HotKV license. Contact sales@hotkv.com.
Options
Section titled “Options”| Option | Effect |
|---|---|
RETENTION milliseconds |
Drop samples older than this, measured back from the server’s current time. 0 (the default) keeps samples forever. |
LABELS label value ... |
Attach label pairs, used to find series with TS.LIST. |
Put RETENTION before LABELS when you use both.
The number of series a server holds is capped by the timeseries.max-series
setting.
Return value
Section titled “Return value”| Case | RESP2 | RESP3 |
|---|---|---|
| Created | Simple string OK |
Simple string OK |
Error replies:
ERR series already exists or limit reachedERR invalid RETENTION valueERR unknown option: namefor an unknown option, or a label without a value.NOLICENSE ...without the license feature.
Examples
Section titled “Examples”127.0.0.1:6379> TS.CREATE temp:kitchen RETENTION 604800000 LABELS room kitchenOK127.0.0.1:6379> TS.CREATE temp:kitchen(error) ERR series already exists or limit reached127.0.0.1:6379> TS.CREATE temp:hall LABELS room(error) ERR unknown option: roomCompatibility
Section titled “Compatibility”HotKV’s own time series API. TS.CREATE shares its name with the
RedisTimeSeries command, but takes only RETENTION and LABELS, and its
error replies differ.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.