-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#194 local cache
- Loading branch information
Showing
9 changed files
with
116 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...rc/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventCacheService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package JGS.CasperEvent.domain.event.service.eventService; | ||
|
||
import JGS.CasperEvent.domain.event.dto.ResponseDto.rushEventResponseDto.RushEventResponseDto; | ||
import JGS.CasperEvent.domain.event.entity.event.RushEvent; | ||
import JGS.CasperEvent.domain.event.repository.eventRepository.RushEventRepository; | ||
import JGS.CasperEvent.global.enums.CustomErrorCode; | ||
import JGS.CasperEvent.global.error.exception.CustomException; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cache.annotation.Cacheable; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class RushEventCacheService { | ||
|
||
private final RushEventRepository rushEventRepository; | ||
|
||
@Cacheable(value = "todayEventCache", key = "#today") | ||
public RushEventResponseDto getTodayEvent(LocalDate today) { | ||
log.info("오늘의 이벤트 캐싱 {}", today); | ||
// 오늘 날짜에 해당하는 모든 이벤트 꺼내옴 | ||
List<RushEvent> rushEventList = rushEventRepository.findByEventDate(today); | ||
|
||
if (rushEventList.isEmpty()) { | ||
throw new CustomException("선착순 이벤트가 존재하지않습니다.", CustomErrorCode.NO_RUSH_EVENT); | ||
} | ||
|
||
if (rushEventList.size() > 1) { | ||
throw new CustomException("선착순 이벤트가 2개 이상 존재합니다.", CustomErrorCode.MULTIPLE_RUSH_EVENTS_FOUND); | ||
} | ||
|
||
return RushEventResponseDto.of(rushEventList.get(0)); | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
...r/src/main/java/JGS/CasperEvent/domain/event/service/eventService/RushEventScheduler.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Server/src/main/java/JGS/CasperEvent/global/config/CacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package JGS.CasperEvent.global.config; | ||
|
||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class CacheConfig { | ||
|
||
@Bean | ||
public CacheManager cacheManager() { | ||
return new ConcurrentMapCacheManager("todayEventCache"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 0 additions & 58 deletions
58
...c/test/java/JGS/CasperEvent/domain/event/service/eventService/RushEventSchedulerTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.