Key expiration

A simple and robust method to keep your Redis database from exceeding it's available memory is to set timeouts on keys that will be automatically evicted after the key's timeout expires. If your application does not need to retain stale or old data, having an effective expiration strategy for your key-space will keep the memory demands for your Redis application more manageable. A popular Redis design pattern using key expiration is to save expired or evicted data into another relational SQL database or other more disk-based NoSQL platform like MongoDB.

There are some aspects of key expiration that you should be aware of when implementing this feature in your application. First, when you call a timeout with the EXPIRE command on ...

Get Mastering Redis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.