Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : 커서 기반 학원 목록 조회 2차 캐시 적용 #149

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public AcademiesByLocationWithScrollResults findAcademiesByLocationWithScroll(
}

@Transactional(readOnly = true)
@Cacheable(cacheNames = "academyByLocation")
public AcademyByLocationWithCursorResults findAcademiesByLocationWithCursor(
AcademyByLocationWithCursorParam param) {
String diagonal = GeometryUtil.makeDiagonal(param.baseLatitude(), param.baseLongitude(), DISTANCE);
Expand All @@ -90,7 +91,6 @@ public AcademyByLocationWithCursorResults findAcademiesByLocationWithCursor(
}

@Transactional(readOnly = true)
@Cacheable(cacheNames = "academyByLocation")
public AcademyByLocationWithCursorAndNotLikeResults findAcademiesByLocationWithCursorAndNotLike(
AcademyByLocationWithCursorParam param) {
String diagonal = GeometryUtil.makeDiagonal(param.baseLatitude(), param.baseLongitude(), DISTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import org.guzzing.studayserver.domain.like.model.Like;
import org.guzzing.studayserver.domain.like.repository.LikeRepository;
import org.guzzing.studayserver.domain.member.model.Member;
import org.guzzing.studayserver.global.config.CaffeineCacheType;
import org.springframework.boot.autoconfigure.cache.CacheType;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -17,11 +20,13 @@ public LikeCommandService(final LikeRepository likeRepository) {
this.likeRepository = likeRepository;
}

@CacheEvict(value = "academyByLocation")
public Like saveLike(final Member member, final Academy academy) {
final Like like = Like.of(member, academy);
return likeRepository.save(like);
}

@CacheEvict(value = "academyByLocation")
public void deleteLike(final long likeId) {
likeRepository.deleteById(likeId);
}
Expand Down
Loading