在hazelcast文檔之外,還有一個名爲「默認」的緩存一些簡短的引用 - 例如,在這裏: http://docs.hazelcast.org/docs/3.6/manual/html-single/index.html#jcache-declarative-configuration是否Hazelcast榮譽器的默認緩存配置
後來,有緩存的默認配置的另一提到這裏: 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有一個「模板」機制,我希望我能得到一個類似的行爲。