SteelReed

Search

Search posts, questions…

Caching & RedisQuestion 15 / 24

Middle

What is cache penetration, and how do null caching and Bloom filters solve it?

Short answer

Penetration: requests ask for keys that do not exist, the cache never hits, so every request reaches the DB. Fix it by caching the empty result or a Bloom filter.

definitely notmaybenot in DBRequest by idValidate inputBloom filter?Return not foundCache, then DB on missCache empty, short TTL

3 points to say:

  1. Validate the input first.
  2. Cache empty results for 30–60 seconds.
  3. A Bloom filter is only certain when it says "no".

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.