Caching

Keeping data close so it need not be recomputed: cache-aside, write-through, time to live, eviction, invalidation, and what happens when the cache empties or fails.

  • 34 cards
  • 3 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Scenarios
  3. Trade-offs and failures

A few cards from the deck

  • Cache: what is it?

    Show the answer

    Fast storage that keeps recently or frequently used data to avoid reading or computing it again.

    It answers faster and relieves the source, at the price of sometimes stale data.

  • The database saturates on reads of the same, very popular product pages. What do you do?

    • A cache-aside in front of the database
    • More web servers
    • Shard the database right away
    • Lengthen the timeout
    Show the answer

    A cache-aside in front of the database

    Repeated reads are served by the cache; the database only sees misses.

  • Cache-aside (lazy loading): what is it?

    Show the answer

    The application reads the cache first; if the data is missing, it reads the source and puts it in the cache.

    Only what is actually requested enters the cache.

  • The cache fails. What is the risk?

    • All reads fall back on the database, which may not cope
    • None, the cache is only an optimisation
    • Data is lost
    • Only writes fail
    Show the answer

    All reads fall back on the database, which may not cope

    A cache you rely on to handle the load must be redundant, and the database protected.