Bird
Raised Fist0

How can you combine transaction history with caching to improve read performance without sacrificing data consistency?

hard📝 Trade-off Q9 of Q15
LLD - Design — Splitwise (Expense Sharing)
How can you combine transaction history with caching to improve read performance without sacrificing data consistency?
AUse a cache that updates only after a delay
BUse a write-through cache that updates cache and database simultaneously
CCache only the oldest transactions
DDisable caching to avoid stale data
Step-by-Step Solution
Solution:
  1. Step 1: Understand caching strategies

    Write-through cache updates both cache and database immediately, ensuring consistency.
  2. Step 2: Compare with other options

    Delayed updates cause stale reads; caching oldest data is inefficient; disabling cache reduces performance.
  3. Final Answer:

    Use a write-through cache that updates cache and database simultaneously -> Option B
  4. Quick Check:

    Consistent caching = write-through cache [OK]
Quick Trick: Write-through cache keeps data consistent [OK]
Common Mistakes:
MISTAKES
  • Using delayed cache updates causing stale data
  • Caching irrelevant data
  • Disabling cache unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes