# Cache Invalidation — Redis

Source: https://www.geekswithgeeks.com/en/redis/redis-cache-invalidation

> Keeping cached data from going stale after a write.

## Two strategies

Let a TTL expire it passively, or **actively delete** the key the moment the underlying data changes — the second is fresher but needs discipline everywhere data is written.

## Delete on write

After updating the source of truth, remove the stale cache entry — the next read will repopulate it.

```bash
# after UPDATE products SET price = 799 WHERE id = 501
DEL product:501
```
