Bird
0
0

Which of the following is the correct way to use @CacheEvict to clear a cache named "users" after a method executes?

easy📝 Syntax Q12 of 15
Spring Boot - Caching
Which of the following is the correct way to use @CacheEvict to clear a cache named "users" after a method executes?
A@CacheEvict(cacheNames = "users", allEntries = true)
B@CacheEvict(cacheName = "users", clearAll = true)
C@CacheEvict(value = "users", removeAll = true)
D@CacheEvict(cache = "users", evictAll = true)
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct attribute names

    The correct attribute to specify cache names is cacheNames or value. To clear all entries, use allEntries = true.
  2. Step 2: Match correct syntax

    @CacheEvict(cacheNames = "users", allEntries = true) uses @CacheEvict(cacheNames = "users", allEntries = true), which is valid syntax.
  3. Final Answer:

    @CacheEvict(cacheNames = "users", allEntries = true) -> Option A
  4. Quick Check:

    cacheNames + allEntries = true [OK]
Quick Trick: Use cacheNames and allEntries=true to clear all cache keys [OK]
Common Mistakes:
  • Using wrong attribute names like cacheName or cache
  • Confusing allEntries with clearAll or removeAll
  • Missing quotes around cache name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes