-
Notifications
You must be signed in to change notification settings - Fork 8
게시글 좋아요 API 구현 #60
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
게시글 좋아요 API 구현 #60
Conversation
nayonsoso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
워낙 코드를 잘 짜주셔서 ㅎㅎ 이번엔 리뷰할게 별로 없었네요!
작업하시느라 수고 많으셨습니다🥳
[정말로 궁금해서 묻는 질문]
'게시글 좋아요 / 좋아요 취소를 하나의 API 에서 한다'는 선택지도 있었을텐데
왜 API 를 따로 만드셨나 궁금해요!
| void 게시글_좋아요_동시성_문제를_해결한다() throws InterruptedException { | ||
|
|
||
| ExecutorService executorService = Executors.newFixedThreadPool(THREAD_POOL_SIZE); | ||
| CountDownLatch doneSignal = new CountDownLatch(THREAD_NUMS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
동시성 테스트..!😲👏
| public record PostLikeResponse( | ||
| Long likeCount, | ||
| Boolean isLiked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[반영 안 해도 되는 개인적 생각]
래퍼 클래스는 "null 이 올 가능성이 있을 때" 만 사용하는 것이 좋다 생각해요. 메모리상으로도 효율적이고, 다른 개발자들에게 null 의 가능성을 알려준다는 것도 중요하다 생각해서요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오,, 해당부분은 제가 크게 놓치고 있었던 내용이네요,,
래퍼클래스의 장점 때문에 무분별하게 사용하고 있었던 것 같은데 null이 올 가능성이 없을때 등 불필요한 상황에서의 래퍼클래스 사용은 지양하는게 좋다는 생각이 드네요. 감사합니다!
단순히 게시글의 좋아요 수를 +-1 하는것 뿐만아니라, 추후 '내가 좋아요한 게시글 조회' 등과 같은 기능확장을 위해서 |
관련 이슈
작업 내용
게시글 좋아요 관련된 API 구현하였습니다.
테스트코드 작성하였습니다.
모든 테스트 정상동작 합니다.
특이 사항
게시글 좋아요 수 갱신 시점에 동시성 이슈 발생하여 내용 작성하였습니다.
게시글_좋아요_고찰.docx
특정 게시글 조회시 isLiked 값도 반환하도록 수정하였습니다.
리뷰 요구사항 (선택)