66import apptive .team5 .alarm .entity .Alarm ;
77import apptive .team5 .alarm .entity .AlarmMessage ;
88import apptive .team5 .alarm .event .AlarmCreatedEvent ;
9+ import apptive .team5 .config .CacheConfig ;
910import apptive .team5 .diary .domain .DiaryEntity ;
1011import apptive .team5 .diary .service .DiaryLowService ;
1112import apptive .team5 .subscribe .domain .Subscribe ;
1213import apptive .team5 .subscribe .service .SubscribeLowService ;
1314import apptive .team5 .user .domain .UserEntity ;
1415import apptive .team5 .user .service .UserLowService ;
1516import lombok .RequiredArgsConstructor ;
17+ import org .springframework .cache .annotation .Cacheable ;
1618import org .springframework .context .ApplicationEventPublisher ;
1719import org .springframework .scheduling .annotation .Async ;
1820import org .springframework .stereotype .Service ;
1921import org .springframework .transaction .annotation .Transactional ;
2022
2123import java .util .List ;
2224
25+ import static apptive .team5 .config .CacheConfig .*;
26+
2327@ Service
2428@ Transactional
2529@ RequiredArgsConstructor
@@ -35,26 +39,26 @@ public class AlarmDispatchService {
3539 private final SubscribeLowService subscribeLowService ;
3640
3741 @ Async ("sendAlarm" )
42+ @ Cacheable (value = LIKE_ALARM_CACHE , key = "'actor:' + #request.actorId() + ':' + 'diary:' + #request.diaryId()" )
3843 public void saveAndDispatchForLike (DiaryLikeAlarmSendRequest request ) {
3944
4045 Long actorId = request .actorId ();
4146 UserEntity actor = userLowService .findById (actorId );
4247 DiaryEntity diary = diaryLowService .findByIdWithUser (request .diaryId ());
4348 UserEntity receiver = diary .getUser ();
4449
45- String title = AlarmMessage .LIKE_ALARM .getMessage ();
4650 String content = actor .getUsername () + "님이 회원님의 킬링파트를 좋아합니다." ;
4751 String deepLink = DIARY_DEEP_LINK_FORMAT .formatted (diary .getId ());
4852
4953 saveAndPublish (receiver , AlarmMessage .LIKE_ALARM , content , deepLink );
5054 }
5155
5256 @ Async ("sendAlarm" )
57+ @ Cacheable (value = SUBSCRIBE_ALARM_CACHE , key = "'subscriber:' + #request.subscriberId() + ':' + 'subscribedToUser:' + #request.subscribedToUserId()" )
5358 public void saveAndDispatchForSubscribe (SubscribeAlarmSendRequest request ) {
5459 UserEntity subscriber = userLowService .findById (request .subscriberId ());
5560 UserEntity receiver = userLowService .findById (request .subscribedToUserId ());
5661
57- String title = AlarmMessage .SUBSCRIBE_ALARM .getMessage ();
5862 String content = subscriber .getUsername () + "님이 회원님을 픽했어요." ;
5963 String deepLink = SUBSCRIBE_DEEP_LINK_FORMAT .formatted (receiver .getId ());
6064
0 commit comments