mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-24 08:25:50 +00:00
#1587 - Fix for propagation of @Cache(nearCache=true)
This commit is contained in:
@@ -79,6 +79,15 @@ public class ServerCacheOptions {
|
||||
copy.maxIdleSecs = maxIdleSecs;
|
||||
copy.maxSecsToLive = maxSecsToLive;
|
||||
copy.trimFrequency = trimFrequency;
|
||||
copy.nearCache = this.nearCache;
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of this object with nearCache option.
|
||||
*/
|
||||
public ServerCacheOptions copy(boolean nearCache) {
|
||||
ServerCacheOptions copy = copy();
|
||||
copy.nearCache = nearCache;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class DefaultCacheHolder {
|
||||
if (tuning != null) {
|
||||
return new ServerCacheOptions(nearCache, tuning).applyDefaults(beanDefault);
|
||||
}
|
||||
return beanDefault.copy();
|
||||
return beanDefault.copy(nearCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.ebean.cache;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ServerCacheOptionsTest {
|
||||
|
||||
@Test
|
||||
public void copy_when_off() {
|
||||
|
||||
ServerCacheOptions basic = new ServerCacheOptions();
|
||||
assertThat(basic.isNearCache()).isFalse();
|
||||
|
||||
ServerCacheOptions copy = basic.copy(true);
|
||||
assertThat(copy.isNearCache()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void copy_when_on() {
|
||||
|
||||
ServerCacheOptions basic = new ServerCacheOptions();
|
||||
basic.setNearCache(true);
|
||||
assertThat(basic.isNearCache()).isTrue();
|
||||
|
||||
ServerCacheOptions copy = basic.copy(false);
|
||||
assertThat(copy.isNearCache()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user