@Cacheable annotation do in Spring Boot?The @Cacheable annotation tells Spring to save the result of a method call in a cache. When the method is called again with the same parameters, Spring returns the cached result instead of running the method again. This speeds up read operations.
@Cacheable?You use the value or cacheNames attribute inside @Cacheable to name the cache. For example, @Cacheable("books") tells Spring to use the cache named "books".
@Cacheable?Spring uses the method parameters as keys in the cache. If parameters change, Spring treats it as a new request and runs the method, then caches the new result separately.
@Cacheable be used for write operations?No, @Cacheable is meant for read caching only. For write or update operations, you use @CachePut or @CacheEvict to update or clear the cache.
@Cacheable in a Spring Boot service method? @Cacheable("items")
public Item getItemById(Long id) {
// Simulate slow database call
return repository.findById(id).orElse(null);
}This caches the result of getItemById so repeated calls with the same id are faster.
@Cacheable do in Spring Boot?@Cacheable caches method results to avoid repeated slow calls.
@Cacheable?The value or cacheNames attribute names the cache to use.
@Cacheable?Spring treats new parameters as a new cache key and caches the new result.
@CachePut updates the cache after a method runs.
@Cacheable?Caching speeds up repeated method calls by returning stored results.
@Cacheable works in Spring Boot and why it is useful for read operations.@Cacheable, @CachePut, and @CacheEvict in Spring Boot caching.