Caching Strategies

Preview — 3 of 10 questions

Which description best matches the cache-aside (lazy loading) pattern?

javascript
1. App checks cache  HIT   return cached value (fast path)
2. App checks cache  MISS  query DB
3. App stores result in cache with TTL
4. App returns result to caller
AThe cache automatically pulls data from the database when a key is missing.
BThe application checks the cache first; on a miss, it fetches from the database, stores the result in cache, then returns it.
CEvery write to the database immediately updates the cache in the same transaction.
DThe cache is pre-populated with all data at startup before any request arrives.

What is the key difference between write-through and write-behind (write-back) caching?

javascript
Write-through:
  App  Cache  DB (synchronous, same request)
  Latency: higher (waits for DB write)
  Durability: strong (data always in DB)

Write-behind (write-back):
  App  Cache  ACK returned immediately
               DB (async, seconds or minutes later)
  Latency: lower
  Durability risk: data in cache only until flush
AWrite-through updates cache and database synchronously on every write; write-behind updates the database asynchronously after acknowledging the write to the cache.
BWrite-through updates the cache only; write-behind updates both cache and database.
CWrite-through is faster because it skips the database entirely.
DWrite-behind is used exclusively for read-heavy workloads.

A cache is full and must evict an entry to make room. Which eviction policy removes the entry that has not been used for the longest time?

ALFU (Least Frequently Used)
BFIFO (First In, First Out)
CLRU (Least Recently Used)
DMRU (Most Recently Used)

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.