Search code examples
node.jsredisaws-lambdaamazon-elasticache

Clear Redis Cache periodically using Lambda


I am writing a Lambda function that connects to AWS ElastiCache Redis. This Lambda function will talk to a database to return a list of records and cache those records to ElastiCache Redis. Sometimes, new records will be added to the database, I want my Lambda to clear Redis cache once a day and recache all records again. Does anyone know how to configure ElastiCache Redis to clear its cache periodically?


Solution

  • If you want to drop cache once a day, just set its expiration to the end of the day.

    But you're saying "drop and recache". How will Redis do it? You need to configure your Lambda (or write another one) to do that for you. And you better compute new values before dropping old ones.