skip to Main Content

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


  1. You can set a timeout on key using the EXPIRE command. See the doc for details.

    Login or Signup to reply.
  2. 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:

    SETEX foo 172800 value
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search