2012-06-07 21 views
13

如果我有以下配置:ehcache.xml中的緩存是否繼承自defaultCache?

<defaultCache timeToIdleSeconds="120" 
     timeToLiveSeconds="120" /> 
<cache name="test" 
     timeToLiveSeconds="300" /> 

會是怎樣的timeToIdleSeconds用於緩存test價值?它會從默認緩存中繼承,因此等於120,還是會採用手冊中給出的默認值,即0(無窮大)?

回答

14

timeToIdleSeconds將是默認值,不會從「defaultCache」繼承。 「defaultCache」有點用詞不當/誤導,因爲它不會爲每個緩存提供「默認值」,但它只是一種指定可以動態添加的緩存配置的方法 - 使用cacheManager.addCache(String cacheName )。

http://www.ehcache.org/ehcache.xml,該代碼的文檔讀取

 
Default Cache configuration. 
These settings will be applied to caches created programmatically using 
CacheManager.add(String cacheName). This element is optional, and using 
CacheManager.add(String cacheName) when its not present will throw CacheException 
The defaultCache has an implicit name "default" which is a reserved cache name. 
+0

我看過的文本,但對我來說似乎不是太清楚。 –

+0

僅供參考,'defaultCache'設置也用於調用'CacheManager#addCacheIfAbsent(String cacheName)'。 –