Interview questions
Question 147 of 254
FreeWhat is the difference between @Cacheable, @CachePut, and @CacheEvict?
Caching & Scheduling
@Cacheable checks the cache first and may skip the method entirely on a hit. @CachePut always executes the method (never skips it) and then updates the cache with the fresh result — used for methods that must always run (like a save/update operation) while still keeping the cache current. @CacheEvict removes an entry (or clears the entire cache with `allEntries = true`) from the cache, typically called on delete/update operations to invalidate now-stale cached data.
Intermediate5 min
