Bird
0
0

What will happen if you annotate a method with @CacheEvict(value = "users", allEntries = true) and call it?

medium📝 component behavior Q5 of 15
Spring Boot - Caching
What will happen if you annotate a method with @CacheEvict(value = "users", allEntries = true) and call it?
ACache entries are refreshed with new data
BOnly the cache entry for the method argument is removed
CCache eviction does not happen without a key
DAll entries in the 'users' cache are removed
Step-by-Step Solution
Solution:
  1. Step 1: Understand @CacheEvict with allEntries=true

    Setting allEntries=true removes all entries in the specified cache.
  2. Step 2: Confirm effect on 'users' cache

    Calling the method clears all cached data under 'users'.
  3. Final Answer:

    All entries in the 'users' cache are removed -> Option D
  4. Quick Check:

    @CacheEvict with allEntries=true clears entire cache [OK]
Quick Trick: allEntries=true clears all cache keys [OK]
Common Mistakes:
  • Thinking only one key is removed without specifying key
  • Assuming cache refresh happens automatically
  • Believing eviction requires a key always

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes