Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BG-343]: 채팅 커서 조회 redis cache 구현 (12h / 6h) #78

Merged
merged 11 commits into from
Aug 12, 2024

Conversation

GGHDMS
Copy link
Member

@GGHDMS GGHDMS commented Aug 11, 2024

Why

채팅 기능 캐시를 구현하였다
처음 구현해서 생각보다 오래 걸렸다

How

레디스 구조

채팅을 sorted set 에 저장하는 형태로 만들고
score 를 채팅 id 로 설정하였다

이때 유저의 정보는 쉽게 바뀔수 있기 때문에
채팅에는 유저 id 만 저장하고
유저 상세 정보는 hash table 에 저장하였다

또한 특정 채팅방에 속한 유저를 한번에 조회하기 위해
chatroomId를 키로 하는 hash table에
유저 id를 리스트로 저장하였다

저장 형태

채팅과 이벤트를 생성할 때 레디스 캐시에 저장되게 만들었다
현재는 채팅방마다 200개가 저장될 수 있게 하였다

조회 형태

  • 이전 채팅 조회
    먼저 레디스를 조회하고 부족한 채팅수 만큼 db를 조회하게 함

  • 이후 채팅 조회
    조회 하려는 커서가 현재 레디스의 score 에 포함이 되는지 확인한다
    만약 포함이 되면 레디스를 통해서 조회를 하고
    포함되지 않으면 db를 호출하여 조회를 한다

Result

image

Link

BG-343

@GGHDMS GGHDMS changed the title [BG-22]: PR 제목 (실제소요시간h / 스토리포인트h) [BG-343]: 채팅 커서 조회 redis cache 구현 (10h / 6h) Aug 11, 2024
@GGHDMS GGHDMS force-pushed the feature/BG-343-chat-cache branch from 194bf57 to 761ad50 Compare August 12, 2024 07:19
@GGHDMS GGHDMS requested a review from Dltmd202 August 12, 2024 07:19
@GGHDMS GGHDMS self-assigned this Aug 12, 2024
@GGHDMS GGHDMS changed the title [BG-343]: 채팅 커서 조회 redis cache 구현 (10h / 6h) [BG-343]: 채팅 커서 조회 redis cache 구현 (12h / 6h) Aug 12, 2024
Copy link

@inmonim inmonim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@JinhyeokFang JinhyeokFang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@Dltmd202 Dltmd202 merged commit 18b51a7 into develop Aug 12, 2024
1 check passed
@Dltmd202 Dltmd202 deleted the feature/BG-343-chat-cache branch August 12, 2024 10:55
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.

4 participants