Bird
0
0

What happens when you call a @Cacheable method with different parameters?

medium📝 Conceptual Q5 of 15
Spring Boot - Caching
What happens when you call a @Cacheable method with different parameters?
AOnly the first parameter caches a result; others do not.
BAll calls return the same cached result regardless of parameters.
CEach unique parameter caches a separate result.
DCache is cleared after each call.
Step-by-Step Solution
Solution:
  1. Step 1: Understand caching key behavior

    Spring caches results based on method parameters as keys. Different parameters create different cache entries.

  2. Step 2: Evaluate options

    Each unique parameter caches a separate result. correctly states each unique parameter caches separately. Others contradict caching logic.

  3. Final Answer:

    Each unique parameter caches a separate result. -> Option C
  4. Quick Check:

    Cache keys = method parameters [OK]
Quick Trick: Cache keys depend on method parameters [OK]
Common Mistakes:
  • Thinking cache ignores parameters
  • Assuming single cache entry for all calls
  • Believing cache clears after each call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes