ehcache 缓存失效时间配置基础问题?

设置默认缓存失效时间5分钟无效,5分钟之后仍然可以访问缓存,配置如下:

 <?xml version="1.0" encoding="GB2312"?>
http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
<diskStore path="java.io.tmpdir"/>

<defaultCache 
maxElementsInMemory="500" 
eternal="false" 
timeToIdleSeconds="300" 
timeToLiveSeconds="300" 
overflowToDisk="true" /> 
</ehcache>

但是,我用下面的方式,配置缓存5分钟之后就失效

<?xml version="1.0" encoding="GB2312"?>
http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
<diskStore path="java.io.tmpdir"/>

<defaultCache 
maxElementsInMemory="500" 
eternal="false" 
timeToIdleSeconds="300" 
timeToLiveSeconds="300" 
overflowToDisk="true" /> 

<cache name="HomeGuideCache" 
maxElementsInMemory="10000" 
eternal="false"
overflowToDisk="false" 
timeToIdleSeconds="300" 
timeToLiveSeconds="300"
memoryStoreEvictionPolicy="LFU" />

<cache name="IHealthTypecache" 
maxElementsInMemory="10000" 
eternal="false"
overflowToDisk="false" 
timeToIdleSeconds="300" 
timeToLiveSeconds="300"
memoryStoreEvictionPolicy="LFU" />


</ehcache>

问题:怎么才能使得系统所有缓存都在5分钟之后失效,也就是都使用默认配置?

应该可以用cache template。你可以看看这个链接:http://www.ehcache.org/documentation/3.0/examples.html#xml-with-107-extension
下面是一个片段截取:

ehcache:expiry
ehcache:none/
/ehcache:expiry
<!--
OPTIONAL
Any further elements in another namespace
-->
/ehcache:cache-template

<!--
A that uses the template above by referencing the cache-template's name in the uses-template attribute:
-->

<!--
Adds the key and value type configuration
-->
ehcache:key-typejava.lang.Long/ehcache:key-type
ehcache:value-typecom.pany.domain.Customer/ehcache:value-type

<!--
  Overwrites the capacity limit set by the template to a new value
-->
<ehcache:heap unit="entries">200</ehcache:heap>

/ehcache:cache