Performance: @EnableCaching annotation
MEDIUM IMPACT
This annotation affects server-side response time by enabling caching, which reduces repeated data processing and speeds up response delivery.
// Add @EnableCaching to @SpringBootApplication or @Configuration class @Service public class ItemService { @Cacheable("items") public List<Item> getItems() { return itemRepository.findAll(); } }
public List<Item> getItems() {
// fetches from database every time
return itemRepository.findAll();
}| Pattern | Server Processing | Database Calls | Memory Usage | Verdict |
|---|---|---|---|---|
| No caching | High on repeated calls | One per request | Low | [X] Bad |
| With @EnableCaching | Low after first call | Single call cached | Increased due to cache | [OK] Good |