[フレーム]
Docs Pricing
Login Book a meeting Try Redis

TS.MADD

Syntax
TS.MADD {key timestamp value}...
Available in:
Redis Open Source / TimeSeries 1.0.0
Time complexity:
O(N*M) when N is the amount of series updated and M is the amount of compaction rules or O(N) with no compaction
ACL categories:
@timeseries, @write, @slow,
Compatibility:
Redis Enterprise and Redis Cloud compatibility

Append new samples to one or more time series

Examples

Required arguments

key

is the key name for the time series.

timestamp

is Unix time (integer, in milliseconds) specifying the sample timestamp or * to set the sample timestamp to the Unix time of the server's clock.

Unix time is the number of milliseconds that have elapsed since 00:00:00 UTC on 1 January 1970, the Unix epoch, without adjustments made due to leap seconds.

value

is numeric data value of the sample (double). The double number should follow RFC 7159 (a JSON standard). The parser rejects overly large values that would not fit in binary64. It does not accept NaN or infinite values.

Notes:

Complexity

If a compaction rule exits on a time series, TS.MADD performance might be reduced. The complexity of TS.MADD is always O(N*M), where N is the amount of series updated and M is the number of compaction rules or O(N) with no compaction.

Examples

Add stock prices at different timestamps

Create two stocks and add their prices at three different timestamps.

127.0.0.1:6379> TS.CREATE stock:A LABELS type stock name A
OK
127.0.0.1:6379> TS.CREATE stock:B LABELS type stock name B
OK
127.0.0.1:6379> TS.MADD stock:A 1000 100 stock:A 1010 110 stock:A 1020 120 stock:B 1000 120 stock:B 1010 110 stock:B 1020 100
1) (integer) 1000
2) (integer) 1010
3) (integer) 1020
4) (integer) 1000
5) (integer) 1010
6) (integer) 1020

Redis Enterprise and Redis Cloud compatibility

Redis
Enterprise
Redis
Cloud
Notes
✅ Supported
✅ Flexible & Annual
✅ Free & Fixed

Return information

One of the following:

  • Array reply, where each element is an Integer reply representing the timestamp of a upserted sample. For each element that is ignored (see IGNORE in TS.CREATE), the reply element value will be the largest timestamp in the time series.
  • Simple error reply in these cases: invalid arguments, wrong key type, duplication policy is BLOCK, or when timestamp is older than the retention period compared to the maximum existing timestamp.

See also

TS.MRANGE | TS.RANGE | TS.MREVRANGE | TS.REVRANGE

RedisTimeSeries

RATE THIS PAGE
Back to top ↑

AltStyle によって変換されたページ (->オリジナル) /