Skip to content

#201 Feat : RedisRepositoryConfig 템플릿 재정의(Object형), Redis에 Queue로 데이터 저장, 10개까지 조회#203

Merged
ls-rain merged 2 commits intodevelopfrom
feat#201
Aug 18, 2024
Merged

#201 Feat : RedisRepositoryConfig 템플릿 재정의(Object형), Redis에 Queue로 데이터 저장, 10개까지 조회#203
ls-rain merged 2 commits intodevelopfrom
feat#201

Conversation

@ls-rain
Copy link
Collaborator

@ls-rain ls-rain commented Jun 3, 2024

  • WSL에서 기존 사용된 JWT값과 함께 사용자의 식별 ID를 저장해줍니다.

  • Key : 사용자 식별 ID, Value : List형의 각 사용자별 최근검색어

  • 아래 사진에서는 CurrentSearch1에서 1이 사용자 ID입니다. 최근검색어 구별을 위해 따로 Key를 만들어줬습니다.
    image

  • 총 10개 까지 검색어를 저장하고, 그 이상이 된다면 Queue로 작동하면서 가장 오래된 검색어를 삭제합니다.

  • 아래 사진은 리스트를 10이상으로 검색하더라도 리스트의 원소개수는 10개를 유지하는 것을 보여주는 예시입니다.
    image

  • 최근검색어 조회 API에서는 검색 키워드, 검색시간을 반환합니다.
    image

@ls-rain ls-rain self-assigned this Jun 3, 2024
Copy link
Member

@MinYeongPark MinYeongPark left a comment

Choose a reason for hiding this comment

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

고생 많으셨습니다!! 구현 감사합니다! 덕분에 참고해서 진행해볼 수 있을 것 같습니다!!👍

개인적으로 궁금한 질문 남겨뒀는데 편하실 때 답변해주시면 감사하겠습니다!

Comment on lines +163 to +166
if(redisSize == 10){
objectRedisTemplate.opsForList().rightPop(key);
}
objectRedisTemplate.opsForList().leftPush(key, value);
Copy link
Member

Choose a reason for hiding this comment

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

오오 이렇게 해서 큐에다가 10개만 유지하도록 구현할 수 있군요! 덕분에 배워갑니다👍

Copy link
Member

Choose a reason for hiding this comment

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

+)
지금 만들어주신 초안 토대로 진행하다가,
이미 큐 안에 들어있는 10개의 검색어 중 또 검색되었을 때(즉 최신 검색어 리스트에 있는 키워드를 한번 더 검색하면 그게 제일 최신 검색어로 올라와야 함)
해당 검색어가 큐에서 빠지고 바로 leftpush 되도록 해야 할 것 같은데
흠 큐여서 어떻게 해야 할지 고민이 되네요..
다음에 이 부분도 같이 고민해서 디벨롭시키면 좋을 것 같습니다!

Copy link
Member

Choose a reason for hiding this comment

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

(앗 혼자서 디벨롭 해달라는 건 아니고 저도 차차 고민해보겠습니다,,)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이해했습니다. [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]순서로 큐에 들어가있을때, "4"가 다시 검색된다면 위 코드대로 한다면 "10"이 삭제되고 4를 다시 집어넣게되어 [4, 1, 2, 3, 4, 5, 6, 7, 8, 9]으로 바뀔것인데 Sorted Set 자료구조로 변경해도 되고, distinct 키워드를 이용해서 로직을 수정하는 방법도 좋을것같습니다ㅎㅎ

Copy link
Member

Choose a reason for hiding this comment

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

아하 답변 감사합니다!!

Comment on lines +174 to +176
String key = "CurrentSearch" + user.getId();
List<Object> objLogs = objectRedisTemplate.opsForList().
range(key, 0, 10);
Copy link
Member

Choose a reason for hiding this comment

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

앗 근데 질문이 있는데, PR 내용에 적어주신 것 중에 keys * 를 했을 때 뜨는 내용에서,

image

2) "RT:yingo24655@gmail.com" <- 이것도 따로 필요해서 생성한 키 인건가요..??

1번 유저yingo24655@gmail.com 는 똑같은 계정을 가리키는데 왜 키가 2개로 따로 나뉘어있는 것인지가 궁금했습니다!
코드에서는 CurrentSearch + userID 으로 키 이름이 생성되는 것 같은데
"RT:yingo24655@gmail.com" 가 무엇인지 헷갈려서 여쭤봅니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

사용자 로그인 인증 토큰값이 "RT:yingo24655@gmail.com"입니다. 이미 JWT를 위해 사용하고 있는 Redis 포트를 같이 사용하는 것을 인지하면 될거 같습니다,,!

Copy link
Member

Choose a reason for hiding this comment

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

앗 그렇군요 놓치고 있었던 부분인데 답변 감사합니다!!

@ls-rain ls-rain merged commit 8673f76 into develop Aug 18, 2024
@ls-rain ls-rain deleted the feat#201 branch August 18, 2024 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants