You add `@Cacheable` to a method but it hits the database every call. List the likely causes.
basicMost often: @EnableCaching is missing, the call is a self-invocation (bypasses the proxy), the method is private/final or the class is not a Spring bean, or the key changes on each call.
@Service
class PriceService {
@Cacheable("prices")
public Price get(String sku) { ... }
public Price wrapper(String sku) { return get(sku); } // cache bypassed
}- Fix self-invocation by moving the cached method to another bean, or by AspectJ mode (
mode = ASPECTJ). - Verify with a cache hit/miss log or
CacheManager.getCache("prices").get(key).
- Does
@Cacheablework on a@PostConstructmethod? No, the proxy is not in place yet. - Does it work on interface or class methods? Both with Spring 6 CGLIB proxies; keep it on the concrete class for consistency.