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

INTERNAL: add builder and transaction for ArcusCacheManager #98

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

oliviarla
Copy link
Collaborator

🔗 Related Issue

⌨️ What I did

  • 현재 대부분의 CacheManager 구현체가 상속받고 있는 AbstractTransactionSupportingCacheManager를 상속받도록 변경했습니다. 이에 따라 spring-context-support, spring-tx 의존성이 추가되었습니다.
  • CacheManager 빌더를 추가했습니다.
  • ArcusCacheConfiguration에 default config를 얻을 수 있는 메서드를 추가했습니다. 이를 통해 빌더를 사용하면 반드시 default config를 입력하지 않아도 됩니다.

@oliviarla oliviarla requested a review from uhm0311 August 20, 2024 11:10
@jhpark816
Copy link
Contributor

@oliviarla
질문입니다.
AbstractTransactionSupportingCacheManager를 상속받아 얻는 이득은 무엇인가요?

@oliviarla
Copy link
Collaborator Author

@jhpark816

AbstractTransactionSupportingCacheManager를 상속받아 얻는 이득은 무엇인가요?

Spring Transaction에 의해 관리될 수 있도록 하는 것이 목적입니다. ArcusCache의 put, evict, clear 메서드가 호출되었을 때 Spring 트랜잭션의 커밋 후에 수행되도록 합니다.

참고로 Spring Transaction의 커밋 시점에 맞추어 작업이 수행되도록 지정할 수 있는데요, beforeCommit, beforeCompletion, afterCommit(AbstractTransactionSupportingCacheManager를 통해 적용하는 시점), afterCompletion 네 가지 시점에 수행되도록 설정할 수 있습니다.

현재 타사 Cache 구현체들에서는 대부분 이를 상속받고 있습니다.

@oliviarla oliviarla force-pushed the builder branch 3 times, most recently from f2bbb1d to 537b019 Compare August 21, 2024 07:43
Copy link
Contributor

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

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

일부 리뷰

public Set<String> getConfiguredCaches() {
return Collections.unmodifiableSet(this.initialCaches.keySet());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

아래 두 메소드는 없어도 될 것 같은데요. 필요한 데가 있나요?

  • getCacheConfigurationFor()
  • getConfiguredCaches()

public ArcusCacheManagerBuilder cacheDefaults(ArcusCacheConfiguration defaultCacheConfiguration) {
this.defaultConfiguration = defaultCacheConfiguration;
return this;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

메소드 명 : defaultCacheConfiguration() or defaultConfiguration() ??

    public ArcusCacheManagerBuilder defaultCacheConfiguration(ArcusCacheConfiguration cacheConfiguration) {
      this.defaultConfiguration = cacheConfiguration;
      return this;
    }

    public ArcusCacheManagerBuilder defaultConfiguration(ArcusCacheConfiguration configuration) {
      this.defaultConfiguration = configuration;
      return this;
    }

return this;
}

public ArcusCacheManagerBuilder initialCacheNames(Set<String> cacheNames) {
Copy link
Contributor

@jhpark816 jhpark816 Aug 22, 2024

Choose a reason for hiding this comment

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

  • initialCacheNames() vs initialCaches()

아래의 다른 메소드까지 고려한다면

  • withInitialCachesWithDefault()
  • withInitialCacheWithConfig()
  • withInitialCachesWithConfig()

이름을 만드는 것이 힘드네요.

.initialCacheNames(Collections.singleton("first-cache"))
.cacheDefaults(withoutPrefix)
.initialCacheNames(Collections.singleton("second-cache"))
.build();
Copy link
Contributor

Choose a reason for hiding this comment

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

아래 코드 형태를 생각해 보았을 것으로 생각합니다.
하지만, 위의 코드를 넣은 것은 cacheDefaults()의 다양한 활용 예를 보이려는 의도인가요?

    ArcusCacheManager cm = ArcusCacheManager.builder(arcusClientPool)
            .withCacheConfiguration("first-cache", withPrefix)
            .withCacheConfiguration("second-cache", withoutPrefix)
            .build();

@@ -41,6 +41,12 @@ public class ArcusCacheConfiguration implements InitializingBean {
private boolean forceFrontCaching;
private boolean allowNullValues = ArcusCache.DEFAULT_ALLOW_NULL_VALUES;

public static ArcusCacheConfiguration defaultCacheConfig() {
ArcusCacheConfiguration config = new ArcusCacheConfiguration();
config.setServiceId("");
Copy link
Contributor

Choose a reason for hiding this comment

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

setServiceId() 수행하지 않으면 어떻게 되나요?

@jhpark816
Copy link
Contributor

jhpark816 commented Aug 23, 2024

@oliviarla
아래와 같이 정리합시다.

  • ServiceId 디폴트 설정을 미리 넣어둡시다.
  • Builder 메소드 용어는 현재 PR대로 합시다.

@jhpark816 jhpark816 merged commit 5c72f9c into naver:develop Aug 23, 2024
3 checks passed
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.

3 participants