Bird
0
0

You want to improve your application's performance by caching database queries using Memorystore for Redis. Which approach is best?

hard📝 Best Practice Q8 of 15
GCP - Cloud Firestore and Bigtable
You want to improve your application's performance by caching database queries using Memorystore for Redis. Which approach is best?
ACache all queries indefinitely without expiration.
BCache query results with a short expiration time and update cache on data changes.
CCache only failed queries to retry later.
DUse Redis to store all application logs.
Step-by-Step Solution
Solution:
  1. Step 1: Understand caching best practices

    Caching query results with expiration ensures fresh data and reduces stale cache.
  2. Step 2: Evaluate other options

    Caching indefinitely risks stale data. Caching failed queries or logs is not caching database queries.
  3. Final Answer:

    Cache query results with a short expiration time and update cache on data changes. -> Option B
  4. Quick Check:

    Cache with expiration and update = best practice [OK]
Quick Trick: Use expiration times to keep cache fresh [OK]
Common Mistakes:
  • Caching data forever causing stale results
  • Caching irrelevant data like logs
  • Ignoring cache invalidation on data change

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes