Merged
Conversation
- slice 반환 Post summary 캐시 - DB동기화 - update/delete시 Post객체&PostSummary객체 무효처리
LJW22222
reviewed
Aug 18, 2025
Comment on lines
+34
to
+38
| public PostCacheDto getPost(Long postId) { | ||
| log.debug("캐시 미스 - DB에서 게시물 조회: postId={}", postId); | ||
| Post post = getPostQueryService.handle(postId); | ||
| return PostCacheDto.from(post); | ||
| } |
Contributor
There was a problem hiding this comment.
해당 부분은 Post를 바로 반환하는게 맞는거 같습니다. DTO를 별도로 발행해서 반환해도 무방하지만, Post라는 Domain 자체가 VO객체이므로 Post를 반환후에, 별도로 데이터를 조합해서 내보내야 하는 경우에 Application계층이나 API계층에서 짜집기해서 내보내는 것이 맞는거 같습니다.
Comment on lines
+45
to
+48
| public Page<Post> getPostList(PostListRequest request) { | ||
| log.debug("캐시 미스 - DB에서 게시물 목록 조회: {}", request); | ||
| return getPostListQueryService.handle(request); | ||
| } |
Contributor
There was a problem hiding this comment.
현재는 Page를 해서 캐시에 저장하고 있는데, 해당 부분은 제가 공용으로 쓸 수 있는 클래스 만들고 해당 클래스를 사용하도록 하면 될 것 같습니다.
Comment on lines
+58
to
+72
| public PostSummaryResponse getPostSummary(Long postId) { | ||
| log.info("캐시 미스 - DB에서 게시물 요약 조회: postId={}", postId); | ||
|
|
||
| if (!getPostQueryService.existsById(postId)) { | ||
| log.info("게시물이 존재하지 않음: postId={}", postId); | ||
| return new PostSummaryResponse( | ||
| null, null, null, null, null, null, null | ||
| ); | ||
| } | ||
|
|
||
| PostSummaryResponse result = getPostQueryService.handlePostSummary(postId); | ||
| log.info("게시물 요약 조회 완료: postId={}", postId); | ||
|
|
||
| return result; | ||
| } |
Comment on lines
29
to
40
| @Bean("redisCacheManager") | ||
| public CacheManager redisCacheManager(RedisConnectionFactory connectionFactory) { | ||
| public RedisCacheManager redisCacheManager(RedisConnectionFactory connectionFactory) { | ||
| return RedisCacheManager.builder(connectionFactory) | ||
| .cacheDefaults(redisCacheConfiguration(Duration.ofMinutes(1))) | ||
| .withInitialCacheConfigurations(customConfigurationMap()) | ||
| .build(); | ||
| } | ||
|
|
||
| @Bean @Primary | ||
| public CacheManager cacheManager(RedisCacheManager redis, MeterRegistry registry) { | ||
| return new MeteredCacheManager(redis, registry); | ||
| public CacheManager cacheManager(@Qualifier("redisCacheManager") RedisCacheManager redisCacheManager, MeterRegistry registry) { | ||
| return new MeteredCacheManager(redisCacheManager, registry); | ||
| } |
Contributor
There was a problem hiding this comment.
CacheManager로 해도 무방하지만, 정말 단순하게 궁금해서 그렇습니다. CacheManager -> RedisCacheManager로 바꾼 의도가 궁금합니다.
Contributor
Author
There was a problem hiding this comment.
이부분 노션 버그 리포트 정리해서 올렸습니다. 참고해주세요!
https://www.notion.so/leeporject/23e37ed0f4f880a9a179f7358efa0d81?source=copy_link
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Post Redis 캐시 구현
개요
게시물 조회 성능 향상을 위한 Redis 캐시 시스템을 구현했습니다.
주요 변경사항
1. 캐시 설정 추가
POST_DETAIL,POST_LIST,POST_SLICE,POST_SUMMARY캐시 타입 정의2. 캐시 DTO 구현
PostCacheDto: Post 도메인 객체의 캐시 전용 DTO
@JsonTypeInfo어노테이션으로 타입 정보 보존from(),toPost()메서드로 변환 지원PostSliceCacheDto: Slice 객체의 캐시 전용 DTO
toSlice()메서드로 Spring Data Slice 복원3. 캐시 서비스 구현
기술적 특징
캐시 TTL 설정
직렬화 최적화
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)로 타입 안전성 보장Location,PostEmotionTag등) 직렬화 지원성능 개선 효과
테스트 고려사항