TS.DEL

Syntax
TS.DEL key fromTimestamp toTimestamp
Available in:
Redis Stack / TimeSeries 1.6.0
Time complexity:
O(N) where N is the number of data points that will be removed

删除给定时间序列中两个时间戳之间的所有样本

示例

必需的参数

key

是时间序列的键名。

fromTimestamp

是范围删除的起始时间戳。

toTimestamp

是范围删除的结束时间戳。

给定的时间戳间隔是闭合的(包含的),这意味着时间戳等于fromTimestamptoTimestamp的样本也会被删除。

备注:

  • 如果fromTimestamp与最大现有时间戳相比超过了保留期限,则删除操作将被放弃并返回错误。
  • 当从定义了压缩规则的时间序列中删除样本时:
    • 如果受影响压缩桶的所有原始样本都可用,则根据剩余的原始样本重新计算压缩值,或者如果压缩桶内的所有原始样本都被删除,则删除压缩值。
    • 如果受影响压缩桶的原始样本已过期,则删除操作将被丢弃并返回错误。
  • 从压缩的时间序列中显式删除样本可能会导致原始数据和压缩数据之间的不一致。压缩过程可能会覆盖这些样本。也就是说,从压缩的时间序列中显式删除超出原始时间序列保留期的样本是安全的。

返回值

返回以下回复之一:

  • Integer reply - 被删除的样本数量
  • [] 在错误情况下(无效参数、错误的键类型等),当timestamp比最大现有时间戳早于保留期时,或当受影响的压缩桶无法重新计算时

示例

Delete range of data points

为特拉维夫和耶路撒冷的温度创建时间序列,然后添加不同的温度样本。

127.0.0.1:6379> TS.CREATE temp:TLV LABELS type temp location TLV
OK
127.0.0.1:6379> TS.CREATE temp:JLM LABELS type temp location JLM
OK
127.0.0.1:6379> TS.MADD temp:TLV 1000 30 temp:TLV 1010 35 temp:TLV 1020 9999 temp:TLV 1030 40
1) (integer) 1000
2) (integer) 1010
3) (integer) 1020
4) (integer) 1030
127.0.0.1:6379> TS.MADD temp:JLM 1005 30 temp:JLM 1015 35 temp:JLM 1025 9999 temp:JLM 1035 40
1) (integer) 1005
2) (integer) 1015
3) (integer) 1025
4) (integer) 1035

删除特拉维夫温度数据点的范围。

127.0.0.1:6379> TS.DEL temp:TLV 1000 1030
(integer) 4

另请参阅

TS.ADD

RedisTimeSeries


RATE THIS PAGE
Back to top ↑