Advertisement
Intermediate Redis, RedisTimeSeries

How do you configure a retention period for a Redis time series so old data is automatically removed after a certain amount of time?

Short answer

You set a retention period, specified in milliseconds, either when creating the time series or by altering it afterward, and Redis automatically removes any data points older than that configured retention window, keeping the time series from growing indefinitely while retaining…

Save Redis mock interview
Advertisement
AModel answer
You set a retention period, specified in milliseconds, either when creating the time series or by altering it afterward, and Redis automatically removes any data points older than that configured retention window, keeping the time series from growing indefinitely while retaining only the recent history your application actually needs.
Example

TS.CREATE sensor_data RETENTION 86400000 -- Keeps only the last 24 hours of raw data

Real-world example
A high frequency sensor monitoring system configures a twenty four hour retention period for its raw data time series, automatically discarding older detailed readings while relying on downsampled aggregates for longer term historical analysis.
Likely follow-ups
  • How do you change the retention period on an already existing time series?
  • What happens to data that has already exceeded the configured retention period?
Related topics