-
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);
}
- 법정동 기준으로 스팟을 조회할 때 데이터를 캐싱하도록 설정
- 글로벌 캐시 전략을 사용
- 캐시 적용 전 : 72ms
- 캐시 적용 후 : 30ms
대략 2배 정도 더 빨라진 것을 확인 가능