naver / arcus-spring

ARCUS as a caching provider for the Spring Cache Abstraction
Apache License 2.0
26 stars 16 forks source link

INTERNAL: provide meaningful methods instead of setters in ArcusCacheConfiguration #101

Closed oliviarla closed 2 months ago

oliviarla commented 2 months ago

🔗 Related Issue

⌨️ What I did

jhpark816 commented 2 months ago

@oliviarla

아래 코드에 있는 config 객체 생성 방식도 참고 바랍니다.

  public LocalCacheManager(String name, int max, int exptime, boolean copyOnRead,
                           boolean copyOnWrite) {
    this.cache = CacheManager.getInstance().getCache(name);
    if (cache == null) {
      CacheConfiguration config =
              new CacheConfiguration(name, max)
                      .copyOnRead(copyOnRead)
                      .copyOnWrite(copyOnWrite)
                      .memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU)
                      .eternal(false)
                      .timeToLiveSeconds(exptime)
                      .timeToIdleSeconds(exptime)
                      .diskExpiryThreadIntervalSeconds(60)
                      .persistence(new PersistenceConfiguration().strategy(
                          PersistenceConfiguration.Strategy.NONE));
      this.cache = new Cache(config, null, null);
      CacheManager.getInstance().addCache(cache);

      logger.info("Arcus k/v local cache is enabled : %s", cache.toString());
    }
  }