Skip to content

Commit

Permalink
#558 [fix] Cache 동시성 이슈 해결
Browse files Browse the repository at this point in the history
#558 [fix] Cache 동시성 이슈 해결
  • Loading branch information
sohyundoh authored Oct 29, 2024
2 parents 07353c3 + bc3f1e2 commit ca90f86
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mile.moim.domain.Moim;
import com.mile.moim.domain.popular.MoimPopularInfo;
import com.mile.moim.repository.MoimPopularInfoRepository;
import com.mile.moim.service.lock.AtomicValidateMoimPopulerInfo;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
Expand All @@ -16,6 +17,7 @@ public class MoimPopularInfoService {


@Cacheable(value = "moimPopularInfo", key = "#moim.id")
@AtomicValidateMoimPopulerInfo
public MoimPopularInfo getMoimPopularInfo(final Moim moim) {
return moimPopularInfoRepository.findByMoimId(moim.getId()).orElseGet(
() -> moimPopularInfoRegister.setMostPopularInfoOfMoim(moim)
Expand Down

0 comments on commit ca90f86

Please sign in to comment.