<!--第三方缓存ehcache-->
<dependency>
<groupId>org.mybatis.caches</groupId>
<artifactId>mybatis-ehcache</artifactId>
<version>1.2.1</version>
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
<!-- 配置缓存文件的路劲
java.io.tmpdir,表示临时文件夹,windows表示在C:\Documents and Settings\Administrator\Local Setting\Temp
-->
<diskStore path="../temp/ehcache"/>
<!-- 设定缓存的默认数据过期策略 -->
<!--
name:缓存名称
maxElementsInMemory:缓存最大个数
eternal:对象是否永久有效,一但设置了,timeout将不起作用
timeToIdleSeconds:设置对象在失效前的允许闲置时间(单位:秒),仅当eternal=false对象不是永久有效时使用
timeToLiveSeconds:设置对象在失效前允许存活时间,最大时间介于创建时间和失效时间之间。仅当eternal=false对象不是永久有效时使用
overflowToDisk:当内存中对象数量达到maxElementsInMemory时,Ehcache将会对象写到磁盘中
diskSpoolBufferSizeMB:这个参数设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB
maxElementsOnDisk:硬盘最大缓存个数
diskPersistent: 是否缓存虚拟机重启期数据
diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认是120秒
memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU。
最近使用(LRU)"策略,其它还有先入先出FIFO,最少使用LFU,较少使用LRU
clearOnFlush:内存数量最大时是否清除
-->
<defaultCache
maxElementsInMemory="1000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"/>
<cache name="userCache"
maxElementsInMemory="1000"
eternal="false"
overflowToDisk="true"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LRU"/>
</ehcache>
最后修改于 2021-10-25 15:57:13
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

