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.
📘 게시판 조회수 증가 로직
🛠️ 구현 기능
1. 조회수 증가 로직
2. 동시성 문제 해결
📋 조회수 증가 로직: 세션 vs 쿠키
🛠️ 조회수 증가 로직 구현 방식
1. 세션을 사용한 조회수 증가 로직
구현 방식
session.setAttribute("viewedPosts", Set<Long>);
장점
단점
2. 쿠키를 사용한 조회수 증가 로직
구현 방식
Cookie("postView", "[1]_[2]_[3]")
장점
단점
🛡️ 왜 쿠키를 선택했는가?
서버 과부하 방지
개인정보 보호
분산 서버 환경 지원
📂 코드 구성
1. Controller
BoardController
는 클라이언트 요청을 처리하며, 상세 조회 시 조회수 증가 로직을 호출합니다.2. Service
BoardService
는 비즈니스 로직을 처리하며, 조회수 증가 로직과 상세 조회 로직을 제공.3. Repository
BoardRepository
는 데이터베이스와의 인터페이스로, 조회수 증가를 처리하는 쿼리를 제공.4. Entity
Board
엔티티는 게시글 데이터를 표현하며, 조회수 필드를 포함.🛡️ 동시성 문제 해결
선택한 방법: 데이터베이스 직접 업데이트
UPDATE Board b SET b.viewCount = b.viewCount + 1 WHERE b.id = :boardId
📝 참고 사항
Closes #232