Spring Cache — @Cacheable, @CachePut, @CacheEvict
개요: 메서드 단위 캐시 선언과 Redis 백엔드 연결을 정리합니다. slug
/knowledge/k-caching-annotation을 유지합니다.
애너테이션
| 애너테이션 | 역할 |
|---|---|
@EnableCaching | 캐싱 기능 활성화 |
@Cacheable | 없으면 실행 후 저장, 있으면 반환 |
@CachePut | 항상 실행 후 캐시 갱신 |
@CacheEvict | 삭제 (allEntries로 prefix 일괄) |
@Caching | 여러 동작 조합 |
boot-base 흐름
@Cacheable / @CacheEvict
→ CachePortCacheManager / CachePortCache
→ CachePort (RedisCacheAdapter)
→ StringRedisTemplate (Lettuce)
값은 JsonCacheValueCodec(JSON)입니다.
앱에 RedisCacheManager를 두지 않습니다.
Gateway JWT는 @Cacheable이 아니라 CachePort 직접입니다.
상세: lib-cache
패턴: 캐시 Cache-Aside
Ref: boot-base