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

[1단계 - DB 복제와 캐시] 테니(나아연) 미션 제출합니다. #63

Open
wants to merge 14 commits into
base: ay-eonii
Choose a base branch
from

Conversation

ay-eonii
Copy link

안녕하세요 카피 ~!! 🐒

리뷰 받게 되어 영광입니다 :>

복제 지연을 해결하기 위해 두 가지 방법을 생각했었는데요,

  1. mysql semi-sync
  2. reader에서 찾지 못하면 writer 에서 조회 ✔️
  3. 로컬 캐시

선택한 방법은 2번입니다!

1번은 적당한 timeout을 가지면 베스트인 방법이라고 생각했으나, 따로 mysql에 플러그인을 설치해야하는 점이 단점으로 다가왔어요. 이는 코드로 해결할 수 있는 부분이 아니며, DB가 변경되면 변경된 DB에 다시 설치가 필요하고 해당 기능을 지원하지 않을 수도 있다고 판단했어요. 그리고 궁극적으로 시도하다가 실패했습니다. 제가 공부한 설정 외에 다른 설정도 필요한 것 같아요.
MySQL 공식문서

3번의 경우에는 쿠폰이라는 도메인이 어찌보면 기간이 짧은 이벤트성이라고 생각을 합니다. 그리고 돈과 관련된 만큼 유효기간이 지난 것이 캐시에 갱신되지 않는다면 조회될 가능성이 있을 것 같습니다.

그래서 2번을 사용하게 되었어요. 허나 Writer에서 다시 조회하는 메서드는 private으로 만들어 외부에서 사용하지 못하게 하였고, readOnly가 아닌 새로운 트랜잭션을 사용하도록 하는 부분을 재사용 가능하게 클래스로 만들었습니다.

리뷰 잘 부탁드려요 😊

Copy link
Member

@tkdgur0906 tkdgur0906 left a comment

Choose a reason for hiding this comment

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

안녕하세요 테니~
리뷰이로 만나게 되서 반갑습니다!

코드 잘 작성해주셔서 우선 간단한 질문들만 남겼습니다!
확인해주시고 다시 요청주세요!

그리고 Coupon 테이블 생성하는 코드가 없어서 테이블을 직접 생성해줘야해서
docker-compose에 init sql 추가 부탁드려요!

@@ -0,0 +1,27 @@
## 기능 요구 사항

### 도메인
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
Author

Choose a reason for hiding this comment

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

다음 요구사항에 필요하다면 점진적으로 추가할 예정입니다 ㅎㅎ..

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "coupon")
public class CouponEntity {
Copy link
Member

Choose a reason for hiding this comment

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

도메인과 엔티티를 분리하셨네요!
이런 방식으로 구현하신 이유가 있나요?

private final CouponRepository couponRepository;
private final TransactionSupporter transactionSupporter;

public Coupon create(Coupon coupon) {
Copy link
Member

Choose a reason for hiding this comment

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

@Transactional을 명시적으로 붙이지 않은 이유가 있을까요?

@DisplayName("최대 길이를 초과하는 경우 예외가 발생한다.")
@Test
void fail_invalidateNameLength() {
String couponName = "카피 반갑습니다 쿠폰. 유효기간은 오늘까지입니다. 감사요";
Copy link
Member

Choose a reason for hiding this comment

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

👋

@@ -0,0 +1,37 @@
package coupon.service;
Copy link
Member

Choose a reason for hiding this comment

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

코드 단에서의 복제 지연 방지를 택하셨네요!
고려해주신 방법중 첫번째가 반동기 방식인데요,
비동기, 반동기, 동기 방식이 각각 db의 어느 작업 단위까지를 보장하는지 궁금해요!

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.

2 participants