Bird
0
0

You want to cache results of a method that returns user profiles but profiles update often. How can you still benefit from caching?

hard📝 Application Q8 of 15
Spring Boot - Caching
You want to cache results of a method that returns user profiles but profiles update often. How can you still benefit from caching?
ADisable caching for this method
BUse cache with a short expiration time to refresh data regularly
CCache indefinitely and never update
DCache only the method parameters
Step-by-Step Solution
Solution:
  1. Step 1: Consider caching with frequent updates

    Short cache expiration allows reuse of data briefly, then refreshes to keep data fresh.
  2. Step 2: Reject unsuitable options

    Indefinite caching causes stale data; disabling caching loses benefits; caching parameters alone does not help.
  3. Final Answer:

    Use cache with a short expiration time to refresh data regularly -> Option B
  4. Quick Check:

    Short expiration balances freshness and speed [OK]
Quick Trick: Set short cache expiry for frequently changing data [OK]
Common Mistakes:
  • Caching data forever causing stale info
  • Disabling caching loses performance gains
  • Caching only parameters instead of results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes