Search code examples
amazon-web-servicesredisaws-cloudformationelastic-cache

AWS elastic cache Redis cluster wide TTL


I am looking for a some property to be set in the cloud formation template for setting a cluster wide TTL, I am not sure if it is possible by cfn, or is there any another way to achieve this.


Solution

  • With Redis there is no parameter for setting the default TTL, the default behaviour is to store key/value for ever. The reason for this is that Redis is a in-memory datastore, whilst one of its primary purposes is caching it's not the only use-case.

    There is however configuration that determines the process that occurs when the maximum memory usage has been reached, this is defined through the maxmemory-policy parameter which in ElastiCache can be configured within the parameter group.

    If this does not match your requirement, you should look at adding the TTL to an abstraction layer in your codebase so that the value is always set on write.

    For more information regarding maxmemory-policy take a look at the Using Redis as an LRU cache page.