-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : AttendeeCacheEvent를 이용해 Attendee를 비동기적으로 캐싱하는 AttendanceServic…
…e 구현 (#62)
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
src/main/java/gdsc/binaryho/imhere/core/lecture/application/AttendeeCacheEvent.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,13 @@ | ||
package gdsc.binaryho.imhere.core.lecture.application; | ||
|
||
import gdsc.binaryho.imhere.core.lecture.model.StudentIds; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class AttendeeCacheEvent { | ||
|
||
private final Long lectureId; | ||
private final StudentIds studentIds; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/gdsc/binaryho/imhere/core/lecture/application/AttendeeCacheService.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,24 @@ | ||
package gdsc.binaryho.imhere.core.lecture.application; | ||
|
||
import gdsc.binaryho.imhere.core.lecture.application.port.AttendeeCacheRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Propagation; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.transaction.event.TransactionPhase; | ||
import org.springframework.transaction.event.TransactionalEventListener; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class AttendeeCacheService { | ||
|
||
private final AttendeeCacheRepository attendeeCacheRepository; | ||
|
||
@Async | ||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) | ||
public void cache(AttendeeCacheEvent event) { | ||
attendeeCacheRepository.cache(event.getLectureId(), event.getStudentIds()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/gdsc/binaryho/imhere/core/lecture/model/StudentIds.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,18 @@ | ||
package gdsc.binaryho.imhere.core.lecture.model; | ||
|
||
import java.util.List; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class StudentIds { | ||
|
||
private final List<Long> studentIds; | ||
|
||
public StudentIds(List<Long> studentIds) { | ||
this.studentIds = studentIds; | ||
} | ||
|
||
public StudentIds(Long studentId) { | ||
this.studentIds = List.of(studentId); | ||
} | ||
} |