在 hazelcast 文档中,有一些对名为“default”的缓存的简短引用 - 例如,这里:http: //docs.hazelcast.org/docs/3.6/manual/html-single/index.html#jcache-declarative -配置
后来这里又提到了缓存默认配置:http: //docs.hazelcast.org/docs/3.6/manual/html-single/index.html#icache-configuration
我想要的是能够配置创建缓存时继承的“默认”设置。例如,给定以下配置片段:
<cache name="default">
<statistics-enabled>true</statistics-enabled>
<management-enabled>true</management-enabled>
<expiry-policy-factory>
<timed-expiry-policy-factory expiry-policy-type="ACCESSED" time-unit="MINUTES" duration-amount="2"/>
</expiry-policy-factory>
</cache>
我希望通过以下测试:
@Test
public void defaultCacheSettingsTest() throws Exception {
CacheManager cacheManager = underTest.get();
Cache cache = cacheManager.createCache("foo", new MutableConfiguration<>());
CompleteConfiguration cacheConfig = (CompleteConfiguration) cache.getConfiguration(CompleteConfiguration.class);
assertThat(cacheConfig.isManagementEnabled(), is(true));
assertThat(cacheConfig.isStatisticsEnabled(), is(true));
assertThat(cacheConfig.getExpiryPolicyFactory(),
is(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 2l)))
);
}
Ehcache 有一个“模板”机制,我希望我能得到类似的行为。