@Cacheable 데이터를 조회할 때, 레디스 캐싱 처리
// FeignClient
@Cacheable(value = "itemReview", key = "#criteria.itemCode", unless = "#result == null")
@GetMapping(".../XXX")
Json<?> getData(@SpringQueryMap Criteria criteria);
value: 레디스 캐시 이름key = "#criteria.itemCode": 레디스 키값을 criteria DTO 내 itemCode 로 설정unless = "#result == null": 결과값이 null 이면 캐싱하지 않겠다.@CacheEvict 메소드를 수행하는 시점에서 value or cacheNames 으로 지정된 레디스 캐시 제거
// FeignClient
@CacheEvict(value = "itemReview")
@PostMapping(".../OOO")
Json<?> postData(@SpringQueryMap Criteria criteria);
@CacheEvict(cacheNames = "XXX", allEntries = true) 해당 cacheNames 을 가지고 있는 모든 캐시 엔트리를 비운다.
// FeignClient
@CacheEvict(cacheNames = "itemReview", allEntries = true)
@PostMapping(".../OOO")
Json<?> postData(@SpringQueryMap Criteria criteria);
value 와 cacheNames 는 같음cacheNames는 application.yml (spring-cloud-config) 에 등록하여 사용http://blog.breakingthat.com/2018/03/19/springboot-ehcache-%EC%A0%81%EC%9A%A9/