-
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.
Refactor :: Notification Cache 적용 #346
기존 schedules 랑 달리 생성, 수정, 삭제 시 cache 값 변동이 필요하여 기존과 다른 로직 변경
- Loading branch information
1 parent
e057ff7
commit 14b5bf8
Showing
4 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
.../com/seugi/api/domain/notification/presentation/dto/response/NotificationEmojiResponse.kt
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.seugi.api.domain.notification.presentation.dto.response | ||
|
||
data class NotificationEmojiResponse( | ||
val emoji: String, | ||
val userList: List<Long>, | ||
val emoji: String? = null, | ||
val userList: List<Long>? = null, | ||
) |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/com/seugi/api/domain/notification/service/NotificationCacheService.kt
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,33 @@ | ||
package com.seugi.api.domain.notification.service | ||
|
||
import com.seugi.api.domain.notification.presentation.dto.response.NotificationResponse | ||
import com.seugi.api.domain.notification.domain.NotificationRepository | ||
import com.seugi.api.domain.notification.domain.mapper.NotificationMapper | ||
import org.springframework.cache.annotation.Cacheable | ||
import org.springframework.cache.annotation.CacheEvict | ||
import org.springframework.data.domain.Pageable | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Propagation | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
class NotificationCacheService( | ||
private val noticeRepository: NotificationRepository, | ||
private val noticeMapper: NotificationMapper | ||
) { | ||
|
||
@Transactional(readOnly = true) | ||
@Cacheable(value = ["notifications"], key = "#workspaceId") | ||
fun getNotices(workspaceId: String, pageable: Pageable): List<NotificationResponse> { | ||
return noticeRepository.findByWorkspaceId(workspaceId, pageable).map { | ||
noticeMapper.transferNoticeResponse( | ||
noticeMapper.toDomain(it) | ||
) | ||
} | ||
} | ||
|
||
@Transactional(propagation = Propagation.REQUIRES_NEW) | ||
@CacheEvict(value = ["notifications"], key = "#workspaceId") | ||
fun deleteCache(workspaceId: String) {} | ||
|
||
} |
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