DBRaven
Caching

Cache Invalidation

Intermediate

Why cache invalidation is hard, how stale data propagates, how invalidation failures cause cache poisoning, and how to design invalidation-safe patterns.

Step 1 of 5

Warm Cache: High Hit Rate

A warm cache serves reads from Redis, absorbing 90-99% of read requests before they reach PostgreSQL. Each cache entry has a TTL that determines its maximum staleness window. Under steady operation, the hit rate is high and database load is low.

user:123
valid

Alice: Premium

TTL 240s

user:456
valid

Bob: Free

TTL 180s

product:789
valid

$49.99

TTL 300s

product:101
valid

In Stock

TTL 90s

feed:top10
valid

[post1, post2, ...]

TTL 60s

Hit Rate

96%

Miss Rate

4%

Cache QPS

3,200

DB QPS

120

Warm cache: 96% hit rate, DB at 120 QPS

Key Takeaways

  • High cache hit rate keeps database load proportional to new/unique requests only
  • TTL controls maximum staleness window: shorter TTL = fresher data, more DB load
1 / 5