TS.CREATE

Since 1.1.0Time seriesDiffers from Redis

Syntax

TS.CREATE key [RETENTION ms] [ENCODING COMPRESSED|UNCOMPRESSED] [CHUNK SIZE size] [DUPLICATE_POLICY BLOCK|FIRST|LAST|MIN|MAX|SUM] [LABELS label value ...]
  • Flags: write
  • ACL categories: @slow, @timeseries, @write
  • Arity: -2

Creates a time series at key: samples, each a timestamp in milliseconds and a floating-point value, kept in timestamp order.

Options

OptionEffect
RETENTION msDrop samples older than this, measured back from the newest; 0 keeps them all (the default).
LABELS label value ...Name-value pairs that TS.MGET, TS.MRANGE and TS.QUERYINDEX select series by.
DUPLICATE_POLICY policyWhat a sample at a timestamp that already has one does: BLOCK (an error), FIRST, LAST, MIN, MAX or SUM.
CHUNK SIZE sizeAccepted, and reported by TS.INFO.
ENCODING COMPRESSED | UNCOMPRESSEDAccepted; KiviDB stores every series one way.

Reply

  • OK.
  • TSDB: key already exists.

Differences from Redis

The default DUPLICATE_POLICY is LAST: a second sample at a timestamp replaces the first. In Redis it is BLOCK, an error. Give DUPLICATE_POLICY BLOCK to get Redis's behaviour. Filed as kividb#127, fixed in 1.2.

Examples

> TS.CREATE temp:1 LABELS room kitchen kind temp
OK
> TS.CREATE temp:1
(error) TSDB: key already exists