Caching strategies
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Layer 3 · Go deeper · 7 min

    Go deeper

    Size it, build it, then make the calls an interviewer will push you on.

    Back of the envelope

    Size it up

    Tap through each step of the arithmetic.

    How many database writes does write-behind save on a hot counter?

      How many stale keys can a rare race leave in the cache?

        Build-up · 5 steps

        Watch a stale set land, then stop it

        Delete-after-commit is the right order, and one race still slips through. Follow a slow reader and a writer on one product key.

        Step 1 of 5

        A reader misses

        A reader asks the cache for the samosa price and misses.

        4 interview moments

        You’re the candidate

        The interviewer pushes on the hard parts. Pick an approach and see how it holds up.

        1. Deep dive 1 of 4

          Interviewer

          “A Big Billion Days-style catalogue is read thousands of times per edit, and a minute of staleness is fine. Which strategy?”

          Your move. Pick an approach:

        2. Deep dive 2 of 4

          Interviewer

          “Product wants debits to feel instant. Someone suggests write-behind for the wallet balance checked before a UPI debit. Do it?”

          Your move. Pick an approach:

        3. Deep dive 3 of 4

          Interviewer

          “Commit-then-delete is in place, but logs show occasional failed deletes and stale pages for minutes. What do you add?”

          Your move. Pick an approach:

        4. Deep dive 4 of 4

          Interviewer

          “Misses read from a database replica. After a price change, the old price keeps reappearing in the cache. Why, and what fixes it?”

          Your move. Pick an approach: