Skip to content

Commit

Permalink
INTERNAL: provide meaningful methods instead of setters in ArcusCache…
Browse files Browse the repository at this point in the history
…Configuration
  • Loading branch information
oliviarla committed Sep 10, 2024
1 parent abe1739 commit 2f17f09
Show file tree
Hide file tree
Showing 7 changed files with 220 additions and 100 deletions.
73 changes: 34 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ public class ArcusConfiguration extends CachingConfigurerSupport {

@Bean
public ArcusCacheConfiguration defaultCacheConfig() {
ArcusCacheConfiguration defaultCacheConfig = new ArcusCacheConfiguration();
defaultCacheConfig.setPrefix("DEFAULT");
defaultCacheConfig.setExpireSeconds(60);
defaultCacheConfig.setTimeoutMilliSeconds(800);
return defaultCacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withPrefix("DEFAULT")
.withExpireSeconds(60)
.withTimeoutMilliSeconds(800);
}

@Bean
Expand All @@ -168,22 +167,20 @@ public class ArcusConfiguration extends CachingConfigurerSupport {

@Bean
public ArcusCacheConfiguration testCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("TEST-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(60);
cacheConfig.setTimeoutMilliSeconds(800);
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("TEST-")
.withPrefix("PRODUCT")
.withExpireSeconds(60)
.withTimeoutMillisSeconds(800);
}

@Bean
public ArcusCacheConfiguration devCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("DEV-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(120);
cacheConfig.setTimeoutMilliSeconds(800);
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("DEV-")
.withPrefix("PRODUCT")
.withExpireSeconds(120)
.withTimeoutMillisSeconds(800);
}

}
Expand Down Expand Up @@ -234,32 +231,30 @@ You can use the front cache to provide fast responsiveness of cache requests. Th
```java
@Bean
public ArcusCacheConfiguration testCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("TEST-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(60);
cacheConfig.setTimeoutMilliSeconds(800);
/* front cache configuration */
cacheConfig.setArcusFrontCache(testArcusFrontCache());
cacheConfig.setFrontExpireSeconds(120);
cacheConfig.setForceFrontCaching(false);
/* front cache configuration */
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("TEST-")
.withPrefix("PRODUCT")
.withExpireSeconds(60)
.withTimeoutMilliSeconds(800)
/* front cache configuration */
.withArcusFrontCache(testArcusFrontCache())
.withFrontExpireSeconds(120)
.withForceFrontCaching(false);
/* front cache configuration */
}

@Bean
public ArcusCacheConfiguration devCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("DEV-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(120);
cacheConfig.setTimeoutMilliSeconds(800);
/* front cache configuration */
cacheConfig.setArcusFrontCache(devArcusFrontCache());
cacheConfig.setFrontExpireSeconds(240);
cacheConfig.setForceFrontCaching(true);
/* front cache configuration */
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("DEV-")
.withPrefix("PRODUCT")
.withExpireSeconds(120)
.withTimeoutMilliSeconds(800)
/* front cache configuration */
.withArcusFrontCache(devArcusFrontCache())
.withFrontExpireSeconds(240)
.withForceFrontCaching(true);
/* front cache configuration */
}

@Bean
Expand Down
66 changes: 31 additions & 35 deletions docs/03-arcus-spring-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class ArcusConfiguration extends CachingConfigurerSupport {

@Bean
public ArcusCacheConfiguration defaultCacheConfig() {
return new ArcusCacheConfiguration();
return ArcusCacheConfiguration.defaultConfig();
}

@Bean
Expand All @@ -139,22 +139,20 @@ public class ArcusConfiguration extends CachingConfigurerSupport {

@Bean
public ArcusCacheConfiguration testCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("TEST-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(60);
cacheConfig.setTimeoutMilliSeconds(800);
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("TEST-")
.withPrefix("PRODUCT")
.withExpireSeconds(60)
.withTimeoutMilliSeconds(800);
}

@Bean
public ArcusCacheConfiguration devCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("DEV-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(120);
cacheConfig.setTimeoutMilliSeconds(800);
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("DEV-")
.withPrefix("PRODUCT")
.withExpireSeconds(120)
.withTimeoutMilliSeconds(800);
}
}
```
Expand Down Expand Up @@ -237,32 +235,30 @@ Front Cache 기능에 대한 설명은 [2장](02-arcus-spring-concept.md#front-c
```java
@Bean
public ArcusCacheConfiguration testCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("TEST-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(60);
cacheConfig.setTimeoutMilliSeconds(800);
/* front cache configuration */
cacheConfig.setArcusFrontCache(testArcusFrontCache());
cacheConfig.setFrontExpireSeconds(120);
cacheConfig.setForceFrontCaching(false);
/* front cache configuration */
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("TEST-")
.withPrefix("PRODUCT")
.withExpireSeconds(60)
.withTimeoutMilliSeconds(800)
/* front cache configuration */
.withArcusFrontCache(testArcusFrontCache())
.withFrontExpireSeconds(120)
.withForceFrontCaching(false);
/* front cache configuration */
}

@Bean
public ArcusCacheConfiguration devCacheConfig() {
ArcusCacheConfiguration cacheConfig = new ArcusCacheConfiguration();
cacheConfig.setServiceId("DEV-");
cacheConfig.setPrefix("PRODUCT");
cacheConfig.setExpireSeconds(120);
cacheConfig.setTimeoutMilliSeconds(800);
/* front cache configuration */
cacheConfig.setArcusFrontCache(devArcusFrontCache());
cacheConfig.setFrontExpireSeconds(240);
cacheConfig.setForceFrontCaching(true);
/* front cache configuration */
return cacheConfig;
return ArcusCacheConfiguration.defaultConfig()
.withServiceId("DEV-")
.withPrefix("PRODUCT")
.withExpireSeconds(120)
.withTimeoutMilliSeconds(800)
/* front cache configuration */
.withArcusFrontCache(devArcusFrontCache())
.withFrontExpireSeconds(240)
.withForceFrontCaching(true);
/* front cache configuration */
}

@Bean
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/com/navercorp/arcus/spring/cache/ArcusCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@
@SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"})
public class ArcusCache extends AbstractValueAdaptingCache {

public static final long DEFAULT_TIMEOUT_MILLISECONDS = 700L;
@Deprecated
public static final boolean DEFAULT_WANT_TO_GET_EXCEPTION = false;
public static final boolean DEFAULT_ALLOW_NULL_VALUES = true;

private final Logger logger = LoggerFactory.getLogger(this.getClass());

private String name;
Expand All @@ -97,12 +92,12 @@ public class ArcusCache extends AbstractValueAdaptingCache {
*/
@Deprecated
public ArcusCache() {
super(DEFAULT_ALLOW_NULL_VALUES);
this.configuration = new ArcusCacheConfiguration();
super(ArcusCacheConfiguration.DEFAULT_ALLOW_NULL_VALUES);
this.configuration = ArcusCacheConfiguration.defaultConfig();
}

public ArcusCache(String name, ArcusClientPool clientPool) {
this(name, clientPool, new ArcusCacheConfiguration());
this(name, clientPool, ArcusCacheConfiguration.defaultConfig());
}

public ArcusCache(String name, ArcusClientPool clientPool, ArcusCacheConfiguration configuration) {
Expand Down
Loading

0 comments on commit 2f17f09

Please sign in to comment.