Bird
0
0

In a Spring Boot application, what is the effect of annotating a method with @CachePut?

easy📝 Conceptual Q1 of 15
Spring Boot - Caching
In a Spring Boot application, what is the effect of annotating a method with @CachePut?
AIt caches the method result only if it is not already cached.
BIt updates the cache with the method's return value every time the method is called.
CIt clears the cache before executing the method.
DIt disables caching for the annotated method.
Step-by-Step Solution
Solution:
  1. Step 1: Understand @CachePut behavior

    @CachePut always updates the cache with the method's return value regardless of existing cache entries.
  2. Step 2: Compare with other annotations

    @Cacheable caches only if no cache exists; @CachePut forces update.
  3. Final Answer:

    It updates the cache with the method's return value every time the method is called. -> Option B
  4. Quick Check:

    @CachePut always updates cache [OK]
Quick Trick: Always updates cache with method return value [OK]
Common Mistakes:
  • Confusing @CachePut with @Cacheable
  • Assuming cache is updated only if empty
  • Thinking @CachePut clears cache

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes