Learn how to use Spring’s caching abstraction to boost performance by reducing DB calls.
| Annotation | Purpose |
|---|---|
@Cacheable |
Caches method result (skips re-execution next time) |
@CachePut |
Updates cache when data changes |
@CacheEvict |
Removes cache entry after deletion |
POST /api/products
{
"name": "Laptop",
"price": 85000
}
GET /api/products/1 # First call hits DB (slow)
GET /api/products/1 # Second call is instant (from cache)
DELETE /api/products/1 # Evicts from cache