diff --git a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventCacheService.java b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventCacheService.java index abb551b9..1f542d3b 100644 --- a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventCacheService.java +++ b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventCacheService.java @@ -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; @@ -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) { @@ -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); + } + } } diff --git a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventService.java b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventService.java index 9c3141a5..a57a9373 100644 --- a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventService.java +++ b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventService.java @@ -227,6 +227,8 @@ public void setRushEvents() { rushEvents.add(rushEvent); } + + rushEventCacheService.setCacheValue(LocalDate.now(), RushEventResponseDto.of(rushEvents.get(2))); }