-
Notifications
You must be signed in to change notification settings - Fork 16
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
좋아요 수 및 좋아요 변경 이력 캐싱 #752
Merged
Merged
좋아요 수 및 좋아요 변경 이력 캐싱 #752
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
51bd229
refactor: 공개된 여행 단건 조회 로직 변경
jjongwa 4fc0442
refactor: 좋아요 여부 변경 기능 redis 사용한로직으로 변경
jjongwa c931afa
feat: 게시물 좋아요 여부 cache write back 스케줄링 기능 추가
jjongwa 392c5f8
feat: 게시물 좋아요 수 캐싱 및 스케줄링 기능 추가
jjongwa b8499f7
feat: 게시물 좋아요 변경 시 캐싱된 좋아요 수 업데이트 로직 추가
jjongwa 9db56c3
test: 게시물 좋아요 변경 테스트 수정
jjongwa ca1aed5
chore: Like Repository 패키지 위치 변경
jjongwa 45d1168
refactor: 변수 네이밍 변경
jjongwa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package hanglog.like.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@RedisHash(value = "likeCount") | ||
public class LikeCount { | ||
|
||
@Id | ||
private Long tripId; | ||
|
||
private Long count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package hanglog.like.domain; | ||
|
||
import java.util.Map; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@RedisHash(value = "memberLike", timeToLive = 5400) | ||
public class MemberLike { | ||
|
||
@Id | ||
private Long memberId; | ||
|
||
private Map<Long, Boolean> likeStatusForTrip; | ||
} |
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/hanglog/like/domain/repository/CustomLikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package hanglog.like.domain.repository; | ||
|
||
import hanglog.like.domain.Likes; | ||
import java.util.List; | ||
|
||
public interface CustomLikeRepository { | ||
|
||
void saveAll(final List<Likes> likes); | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/hanglog/like/domain/repository/LikeCountRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package hanglog.like.domain.repository; | ||
|
||
import hanglog.like.domain.LikeCount; | ||
import java.util.List; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface LikeCountRepository extends CrudRepository<LikeCount, Long> { | ||
|
||
List<LikeCount> findLikeCountsByTripIdIn(final List<Long> tripIds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/hanglog/like/domain/repository/MemberLikeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package hanglog.like.domain.repository; | ||
|
||
import hanglog.like.domain.MemberLike; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface MemberLikeRepository extends CrudRepository<MemberLike, Long> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package hanglog.like.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class TripLikeCount { | ||
|
||
private final long tripId; | ||
private final long count; | ||
} |
37 changes: 37 additions & 0 deletions
37
backend/src/main/java/hanglog/like/infrastrcutrue/CustomLikeRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package hanglog.like.infrastrcutrue; | ||
|
||
import hanglog.like.domain.Likes; | ||
import hanglog.like.domain.repository.CustomLikeRepository; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; | ||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class CustomLikeRepositoryImpl implements CustomLikeRepository { | ||
|
||
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; | ||
|
||
@Override | ||
public void saveAll(final List<Likes> likes) { | ||
final String sql = """ | ||
INSERT INTO likes (trip_id, member_id) | ||
VALUES (:tripId, :memberId) | ||
"""; | ||
namedParameterJdbcTemplate.batchUpdate(sql, getLikesToSqlParameterSources(likes)); | ||
} | ||
|
||
private MapSqlParameterSource[] getLikesToSqlParameterSources(final List<Likes> likes) { | ||
return likes.stream() | ||
.map(this::getLikeToSqlParameterSource) | ||
.toArray(MapSqlParameterSource[]::new); | ||
} | ||
|
||
private MapSqlParameterSource getLikeToSqlParameterSource(final Likes likes) { | ||
return new MapSqlParameterSource() | ||
.addValue("tripId", likes.getTripId()) | ||
.addValue("memberId", likes.getMemberId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
굉장합니다!!!!!!!!신기합니다!!!
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.
홍고가 만들어 놓은 일일 환율 저장 로직 참고한건데요!!!!! 본인 칭찬인가요!!!!!!!!
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.
아니ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 요 스케줄링 아래 캐싱로직말한거였는데 제가 이상한 포인트에서 댓글을 달았군요 ㅋ ㅋ ㅋ