TS.ADD
Since 1.1.0Time seriesDiffers from Redis
Syntax
TS.ADD key timestamp value [RETENTION ms] [ENCODING ...] [CHUNK SIZE size] [ON DUPLICATE policy] [LABELS label value ...]Adds a sample to the time series at key: timestamp in milliseconds, or * for the server's clock, and value, a floating-point number or NaN. A missing series is created, with the RETENTION, LABELS, ON_DUPLICATE (its duplicate policy) and other options TS.CREATE takes.
Samples can be added out of order. One at a timestamp that already has a sample follows the series' duplicate policy, or ON_DUPLICATE policy for this sample.
Reply
- The timestamp stored.
TSDB: Duplicate sample in BLOCK policyunderBLOCK.
Differences from Redis
Without a duplicate policy, a sample at a timestamp that already has one replaces it; Redis refuses it. See TS.CREATE.
Examples
> TS.ADD temp:1 1000 20.5
(integer) 1000
> TS.ADD temp:1 2000 21
(integer) 2000
> TS.CREATE b DUPLICATE_POLICY BLOCK
OK
> TS.ADD b 1000 1
(integer) 1000
> TS.ADD b 1000 2
(error) TSDB: Duplicate sample in BLOCK policy