I’m using Redis to store json messages, which need to be consumed by other services. I want the data to store in Redis for 2 days and the data need to be deleted after the 2 days.
Is there any approach to achieve it?
I’m using Redis to store json messages, which need to be consumed by other services. I want the data to store in Redis for 2 days and the data need to be deleted after the 2 days.
Is there any approach to achieve it?
2
Answers
You can set a timeout on key using the
EXPIRE
command. See the doc for details.Assuming that you are storing the data in a String—which is likely if you’re using ElastiCache—you can SET the value and EXPIRE it in a single command: