Bird
0
0

You have this code snippet for versioning cache invalidation:

medium📝 Debug Q14 of 15
Rest API - Caching Strategies
You have this code snippet for versioning cache invalidation:
cache = { 'v1': data1 }
function getData(version) {
  return cache[version];
}

// Later
cache['v2'] = newData;
What is the main bug if the client still requests v1 after update?
ACache throws an error because version key is missing
BClient gets stale data because old version is still cached
CCache automatically updates old version to new data
DClient cannot access any cached data
Step-by-Step Solution
Solution:
  1. Step 1: Understand versioning cache behavior

    Old version 'v1' remains in cache, so requests for it get stale data.
  2. Step 2: Identify bug impact

    Client requesting 'v1' does not see 'v2' data, causing stale responses.
  3. Final Answer:

    Client gets stale data because old version is still cached -> Option B
  4. Quick Check:

    Old version key returns stale data [OK]
Quick Trick: Old version keys keep stale data unless removed [OK]
Common Mistakes:
MISTAKES
  • Assuming cache auto-updates old versions
  • Expecting errors on missing keys
  • Thinking client loses all cache access

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes