Skip to content

[Refactor] Redis 읽음 포인터 기반 메시지 읽음 처리 개선 - #487

Merged
sammool merged 1 commit into
developfrom
refactor/486-message-read-pointer
Aug 13, 2026
Merged

sammool merged 1 commit into
developfrom
refactor/486-message-read-pointer

Conversation

@sammool

@sammool sammool commented Aug 13, 2026

Copy link
Copy Markdown
Member

PR 제목

[Refactor] Redis 읽음 포인터 기반 메시지 읽음 처리 개선

변경 사항

  • 메시지별 readCount 변경 방식에서 사용자별 lastReadMessageId 포인터 방식으로 읽음 처리 구조 변경
  • 사용자별 읽음 포인터를 Redis Hash로 캐싱
  • 메시지 조회 시 메시지 ID와 수신자의 읽음 포인터를 비교하여 readCount 동적 계산
  • 메시지 읽음 처리 시 Messages 테이블의 개별·벌크 UPDATE 제거

작업 내용 체크

  • Redis 읽음 포인터 캐시 추가
  • 읽음 포인터 캐시 미스 시 DB 조회 및 Redis 적재
  • 메시지 조회 결과의 readCount 동적 계산
  • 채팅방 참여 여부 검증
  • Messages.readCount 개별 변경 제거
  • 메시지 읽음 처리 벌크 UPDATE 제거
  • 기존 포인터와 최신 포인터 사이의 메시지 ID 조회
  • DB 커밋 후 Redis 읽음 포인터 갱신
  • compileJava 성공

관련 이슈

기타 공유 사항

  • 최근 메시지와 읽음 포인터가 모두 Redis에 존재하면 메시지 조회 시 DB 접근 없이 readCount를 계산합니다.
  • 두 읽음 API는 내부적으로 동일한 포인터 범위 처리 로직을 사용하며, 새로 읽힌 메시지 개수만큼 STOMP 이벤트를 발송합니다.
  • Redis 포인터 갱신에 실패하면 해당 방의 포인터 캐시를 삭제하고, 다음 조회 시 DB 값을 기준으로 다시 적재합니다.
  • 신규 테스트 코드는 추가하지 않았으며, 기존 전체 테스트 실행 결과 BUILD SUCCESSFUL을 확인했습니다.

@sammool sammool self-assigned this Aug 13, 2026
@sammool
sammool merged commit e712a7d into develop Aug 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Architecture] 카카오톡 아키텍처 도입: 캐시 효율 극대화를 위한 동적 읽음 처리

1 participant