ehcache 缓存时间配置问题?

本人想让系统中的所有缓存都5分钟失效。在配置文件中设置如下:

<?xml version="1.0" encoding="GB2312"?>
<ehcache xmlns:xsi="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分钟之后,缓存仍然有效,如果我用下面这样的配置,缓存 5分钟之后就失效了。

<?xml version="1.0" encoding="GB2312"?>
<ehcache xmlns:xsi="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>

问题1:如果我要系统都使用默认缓存,且5分钟失效,应该怎么配置?

阅读 6k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进