-
Notifications
You must be signed in to change notification settings - Fork 4
Redis Cache
김경원 edited this page Nov 18, 2021
·
3 revisions
- 자주 조회 되지만, 업데이트가 빈번하게 일어나지 않는 대상 (스팟 - 관리자가 스팟을 등록할 때까지 스팟의 전체 목록은 변하지 않음)
@Cacheable(key="#realAddress", value="getSpotsFromAddress")
public ListSpotResponse getSpotsFromAddress(String realAddress) {
String address[] = realAddress.split(" ");
if(address.length < 3)
throw new IllegalArgumentException("Wrong address");
String city = address[0];
String dong = address[2];
List<Spot> spotList = spotRepo.findAllByCityAndDong(city, dong);
return new ListSpotResponse(spotList);
}
- 법정동 기준으로 스팟을 조회할 때 데이터를 캐싱하도록 설정
- 글로벌 캐시 전략을 사용
-
100 쓰레드, 200번 씩 호출
-
캐시 적용 전
-
캐시 적용 후
대략 3배 이상의 속도 차이를 보이므로 유의미함을 알 수 있음