Skip to content

Commit

Permalink
feat: apply cache
Browse files Browse the repository at this point in the history
  • Loading branch information
yumyeonghan committed Dec 22, 2023
1 parent 77e612b commit a15d96a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import coffeemeet.server.user.implement.UserQuery;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
Expand Down Expand Up @@ -44,11 +45,12 @@ public List<ChattingRoomHistoryDto> searchChattingRoomHistories(Long userId) {
.toList();
}

// TODO: 11/20/23 캐쉬 로직 적용
@Cacheable(value = "chattingMessageHistories", key = "{#roomHistoryId, #firstMessageId, #pageSize}")
public ChattingHistoryListDto searchChattingMessageHistories(Long roomHistoryId,
Long firstMessageId, int pageSize) {
ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryQuery.getChattingRoomHistoryBy(
roomHistoryId);
// TODO: 12/22/23 채팅방 3일 지난거면 응답 x
List<ChattingMessageHistory> messageHistories = chattingMessageHistoryQuery.getMessageHistories(
chattingRoomHistory, firstMessageId,
pageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import coffeemeet.server.user.domain.User;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import java.time.LocalDateTime;

public record ChattingHistory(
Expand All @@ -11,6 +15,8 @@ public record ChattingHistory(
String content,
String profileImageUrl,
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
LocalDateTime createdAt
) {

Expand Down

0 comments on commit a15d96a

Please sign in to comment.