Closed Hchanghyeon closed 9 months ago
@Transactional(readOnly = true) public GamesAndLocationResponse findGamesWithInAddress( final String addressDepth1, final String addressDepth2 ) { final MainAddressResponse mainAddressResponse = addressService.findMainAddressByNames(addressDepth1, addressDepth2); final List<Game> games = gameRepository.findGamesWithInAddress( mainAddressResponse.getAddressDepth1(), mainAddressResponse.getAddressDepth2() ); final MapPolygon polygon = getMapPolygon(mainAddressResponse); // AOP 내부에서 @Cacheable 호출 final List<GameResponse> gameResponses = games.stream() .map(game -> GameResponse.of(game, getMemberResponses(game, CONFIRMED))) .toList(); return GamesAndLocationResponse.of(gameResponses, polygon); } @Cacheable("polygon") // Self Invocation 문제로 동작 안함 public MapPolygon getMapPolygon(final MainAddressResponse mainAddressResponse) { return mapPolygonRepository.findByAddressDepth1AndAddressDepth2( mainAddressResponse.getAddressDepth1(), mainAddressResponse.getAddressDepth2() ); }
위와 같이 getMapPolygon을 호출했을 때 @Cacheable이 동작하지 못하는 현상 발생
해결: Self Invocation 트러블 슈팅
문제 상황
위와 같이 getMapPolygon을 호출했을 때 @Cacheable이 동작하지 못하는 현상 발생