Skip to content

Commit

Permalink
feat: single 결과 조회에 캐싱 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seong-wooo committed Sep 20, 2023
1 parent 9985160 commit 79c4a8b
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import online.partyrun.partyrunbattleservice.domain.single.exception.InvalidSingleOwnerException;
import online.partyrun.partyrunbattleservice.domain.single.exception.SingleNotFoundException;
import online.partyrun.partyrunbattleservice.domain.single.repository.SingleRepository;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -29,6 +30,7 @@ public SingleIdResponse create(String runnerId, SingleRunnerRecordsRequest reque
return new SingleIdResponse(newSingleRecord.getId());
}

@Cacheable(value = "single", key = "#singleId.concat('-').concat(#runnerId)")
public SingleResponse getSingle(String singleId, String runnerId) {
final Single single = singleRepository.findById(singleId).orElseThrow(() -> new SingleNotFoundException(singleId));
if (!single.isOwner(runnerId)) {
Expand Down

0 comments on commit 79c4a8b

Please sign in to comment.