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

basic spec used to caches without custom spec, readme fix #105

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ coffee-boots.cache.spec.myCache=maximumSize=100000,expireAfterWrite=1m

More information is in [issue#44](https://github.com/stepio/coffee-boots/issues/44) or [commit#a134dc6](https://github.com/stepio/coffee-boots/commit/a134dc60843b46b6a69b00ce4449c510b301f534#diff-798aa55948ec42d85da39f34a917b73f).

7. Use `coffee-boots.cache.default-spec` to define "basic" cache configuration with common key-value pairs to be reused by all other custom cache configurations. This allows simplifying custom configurations if necessary.
7. Use `coffee-boots.cache.basic-spec` to define "basic" cache configuration with common key-value pairs to be reused by all other custom cache configurations. This allows simplifying custom configurations if necessary.

More information is in [issue#43](https://github.com/stepio/coffee-boots/issues/43) or [commit#2a38d5b](https://github.com/stepio/coffee-boots/commit/2a38d5b3ca7e12c2cbc152e2b5f5bf0aa3233f34#diff-a6f66d25e49c3ad808097932be3df2d0).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ public void setEnvironment(Environment environment) {

public String getCaffeineSpec(String name) {
String custom = this.environment.getProperty(composeKey(name));
if (StringUtils.isEmpty(custom)) {
return null;
}
String basic = this.environment.getProperty(CACHE_BASIC_SPEC);
if (StringUtils.hasText(basic)) {
return mergeSpecs(basic, custom);
Expand All @@ -46,7 +43,9 @@ protected static String composeKey(String name) {
protected static String mergeSpecs(String... specs) {
Map<String, String> merged = new HashMap<>();
for (String spec : specs) {
merged.putAll(split(spec));
if (spec != null) {
merged.putAll(split(spec));
}
}
return join(merged);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ public void testGetCaffeineSpecNotDefined() {
.contains("maximumSize=5000", "expireAfterWrite=12h", ",");
}

@Test
public void testGetCaffeineSpecBasicForCacheWithoutCustomSpec() {
assertThat(this.caffeineSpecResolver.getCaffeineSpec("unspeced"))
.isEqualTo("maximumSize=100");
doReturn(null)
.when(this.environment)
.getProperty(eq(CACHE_BASIC_SPEC));
assertThat(this.caffeineSpecResolver.getCaffeineSpec("unspeced"))
.isNull();
}

@Test
public void testGetCaffeineSpecMalformed() {
doReturn("dummy")
Expand Down