Skip to content

Commit

Permalink
fix: 테스트 API 호출 시 로컬 캐시 갱신하도록수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wjddn2165 committed Aug 21, 2024
1 parent 7872f39 commit f0bf66f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import JGS.CasperEvent.global.error.exception.CustomException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

Expand All @@ -19,6 +21,7 @@
public class RushEventCacheService {

private final RushEventRepository rushEventRepository;
private final CacheManager cacheManager;

@Cacheable(value = "todayEventCache", key = "#today")
public RushEventResponseDto getTodayEvent(LocalDate today) {
Expand All @@ -36,4 +39,11 @@ public RushEventResponseDto getTodayEvent(LocalDate today) {

return RushEventResponseDto.of(rushEventList.get(0));
}

public void setCacheValue(LocalDate today, RushEventResponseDto rushEvent) {
Cache cache = cacheManager.getCache("todayEventCache");
if (cache != null) {
cache.put(today, rushEvent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ public void setRushEvents() {

rushEvents.add(rushEvent);
}

rushEventCacheService.setCacheValue(LocalDate.now(), RushEventResponseDto.of(rushEvents.get(2)));
}


Expand Down

0 comments on commit f0bf66f

Please sign in to comment.