BeginnerCaching
Customers see yesterday's price
A product cache with a 24-hour TTL keeps showing old prices after an update.
The setup today
Product details, including the price, are cached in Redis with cache-aside: on a miss the service reads the database and caches the product for a day. The admin tool updates prices directly in the database.
Current configuration
read: GET product:{id} -> miss -> SELECT ... -> SET product:{id} ... EX 86400
admin: UPDATE products SET price = ? WHERE id = ?
# nothing touches the cache when a price changesWhat you know
- Prices change about 50 times a day.
- Customers see an old price for hours; checkout charges the database price, so some see a different total.
The new requirement
The business wants a price change to be visible within a minute, and customers must never be charged a price they were not shown.
Make the call
2 questions · first-try answers earn the most XP
What a strong answer also covers
- If several services cache prices, publish a price-changed event so each can invalidate its own copy.
- Pages cached at the CDN need a purge or a short TTL too, or the HTML still shows the old price.
- Version cache keys when the cached format changes, so a deploy never reads old shapes.
- Measure staleness: sample cached values against the database and alert on mismatches.