diff --git a/lime-api/src/main/java/com/programmers/lime/domains/chat/application/ChatService.java b/lime-api/src/main/java/com/programmers/lime/domains/chat/application/ChatService.java index 16546534..cb496a22 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/chat/application/ChatService.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/chat/application/ChatService.java @@ -5,6 +5,7 @@ import java.time.ZoneId; import java.util.List; +import org.springframework.cache.annotation.Cacheable; import org.springframework.context.ApplicationEventPublisher; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.stereotype.Service; @@ -126,6 +127,7 @@ public void sendExitMessageToChatRoom(final Long chatRoomId) { simpMessagingTemplate.convertAndSend("/subscribe/rooms/exit/" + chatRoomId, chatInfoWithMember); } + @Cacheable(value = "chat", key = "#chatRoomId + '_' + #parameters.cursorId + '_' + #parameters.size") public ChatGetCursorServiceResponse getChatByCursor( final Long chatRoomId, final CursorPageParameters parameters diff --git a/lime-api/src/main/java/com/programmers/lime/global/cache/CacheType.java b/lime-api/src/main/java/com/programmers/lime/global/cache/CacheType.java index 415eb3e4..61aec554 100644 --- a/lime-api/src/main/java/com/programmers/lime/global/cache/CacheType.java +++ b/lime-api/src/main/java/com/programmers/lime/global/cache/CacheType.java @@ -7,7 +7,8 @@ @RequiredArgsConstructor public enum CacheType { - REFRESH_TOKEN("refreshToken", 1209600, 10000); + REFRESH_TOKEN("refreshToken", 1209600, 10000), + CHAT_CACHE("chat", 24 * 3600, 500000); private final String cacheName; private final int expireAfterWrite;