ehcache的xml配置

Ehcache是Java缓存框架 EhCache EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,还能支持集群的缓存,是Hibernate中默认的CacheProvider,可以单独使用,也可以整合到Spring中使用。


以下附上Ehcache的xml配置:

<ehcache>
	<!-- 如果缓存支持硬盘存储,则指定硬盘的存储路径 -->
    <diskStore path="java.io.tmpdir"/>
	<!-- 
		maxElementsInMemory="10000": 内存中支持的最大对象存储数量
		eternal="false": 是否在内存中永久存储. 建议为false,如果为true,则后面两个参数无效,即不会有时间的限制
		timeToIdleSeconds="20": 如果20秒没有访问此对象,则对象销毁
		timeToLiveSeconds="120" 对象的总存活时间,120之后无论访问多么频繁都会销毁
		overflowToDisk="true": 是否支持溢出到硬盘, 建议为true
		memoryStoreEvictionPolicy="LRU" 内存的替换算法
						FIFO 先进先出
						LRU 按时间计算
						LFU 按频率计算
		diskPersistent="false"   是否支持硬盘的持久化, 多个相同的项目共享数据
        diskExpiryThreadIntervalSeconds="120"  存储到硬盘中的时间,100秒,则如果下此JVM启动的时间间隔少于100则可以访问到前面的数据,否则访问不到
	
	 -->
    <defaultCache
            maxElementsInMemory="4"
            eternal="true"
            timeToIdleSeconds="100"
            timeToLiveSeconds="200"
            overflowToDisk="false"
            memoryStoreEvictionPolicy="LFU"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="15"
     />
</ehcache>


原文地址:https://www.cnblogs.com/catgwj/p/7503299.html