<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
<diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp"/>
<defaultCache
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="100"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="100"
memoryStoreEvictionPolicy="LRU"
statistics="false"
/>
<cache name="itemSearchCache"
maxElementsInMemory="3000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"
diskSpoolBufferSizeMB="30"
maxElementsOnDisk="100"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="100"
memoryStoreEvictionPolicy="LFU"
statistics="false"
/>
</ehcache>
<defaultCache>元素:设定缓存默认过期策略;
<cache>元素:设定具体的命名缓存的数据过期策略;
<cache>的属性
name:缓存名称,通常为缓存对象的类名
maxElementsInMemory:设置基于内存的缓存可存放对象的最大数目;
maxElementsOnDisk:设置基于硬盘的缓存可存放对象的最大数目;
eternal:如果为true,表示对象记过不会过期,此时会忽略timeToIdleSeconds和timeToLiveSeconds属性,默认为false;
timeToLiveSeconds:设定对象允许存在于缓存中的最长时间,以秒为单位。当对象自从被存放到缓存中后,如果 处于缓存中的时间超过了timeToLiveSeconds属性值,这个对象就会过期。当对象过期,ehcahe将把它从缓存中清除。只有当eternal属性为false,该属性才有效。如属性值 为0,则表示可以无限期地存放于缓存中。timeToLiveSeconds必须大于timeToIdleSeconds属性,才有意义。
overflowToDisk:如果为true,表示当基于内在的缓存中的对象数目达到了maxElementsInMemory界限后,会把溢出的对象写到基于硬盘的缓存中。