|
|
@@ -0,0 +1,60 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<ehcache updateCheck="false" name="defaultCache">
|
|
|
+
|
|
|
+ <!--
|
|
|
+ diskStore:为缓存路径,ehcache分为内存和磁盘两级,此属性定义磁盘的缓存位置,可以自定义目录,确保用户有权限即可。参数解释如下:
|
|
|
+ user.home – 用户主目录
|
|
|
+ user.dir – 用户当前工作目录
|
|
|
+ java.io.tmpdir – 默认临时文件路径
|
|
|
+ -->
|
|
|
+
|
|
|
+ <!-- maxElementsInMemory:内存中最大缓存对象数,根据服务器资源配置 -->
|
|
|
+ <!-- eternal: 默认为false,设置true表示对象永不过期,此时会忽略timeToIdleSeconds和timeToLiveSeconds属性, -->
|
|
|
+ <!-- maxElementsOnDisk:硬盘中最大缓存对象数,若是0表示无穷大 -->
|
|
|
+ <!-- overflowToDisk:true表示当内存缓存的对象数目达到了maxElementsInMemory界限后,会把溢出的对象写到硬盘缓存中。
|
|
|
+ 注意:如果缓存的对象要写入到硬盘中的话,则该对象必须实现了Serializable接口才行。-->
|
|
|
+ <!-- diskSpoolBufferSizeMB:磁盘缓存区大小,默认为30MB。每个Cache都应该有自己的一个缓存区。-->
|
|
|
+ <!-- diskPersistent:是否缓存虚拟机重启期数据 -->
|
|
|
+ <!-- diskExpiryThreadIntervalSeconds:磁盘失效线程运行时间间隔,默认为120秒 -->
|
|
|
+
|
|
|
+ <!-- timeToIdleSeconds: 设定允许对象处于空闲状态的最长时间,单位(秒)。自对象最近一次被访问后,
|
|
|
+ 空闲时间超过了timeToIdleSeconds属性值,这个对象就会过期,如果该属性值为0,则对象无限期地处于空闲状态
|
|
|
+ EHCache将把它从缓存中清空。只有当eternal属性为false,该属性才有效。
|
|
|
+ -->
|
|
|
+
|
|
|
+ <!-- timeToLiveSeconds:设定允许对象存在于缓存中的最长时间,单位(秒)。自对象被存放到缓存中后,
|
|
|
+ 在缓存中的时间超过了timeToLiveSeconds属性值,这个对象就会过期,如果该属性值为0,则对象无限期地存在于缓存中。
|
|
|
+ EHCache将把它从缓存中清除。只有当eternal属性为false,该属性才有效。timeToLiveSeconds必须大于timeToIdleSeconds属性,才有意义 -->
|
|
|
+
|
|
|
+ <!-- memoryStoreEvictionPolicy:当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。
|
|
|
+ 可选策略有:LRU(最近最少使用,默认策略)、FIFO(先进先出)、LFU(最少访问次数)。-->
|
|
|
+
|
|
|
+ <!-- 默认缓存 -->
|
|
|
+ <defaultCache
|
|
|
+ maxElementsInMemory="10000"
|
|
|
+ eternal="false"
|
|
|
+ overflowToDisk="false"
|
|
|
+ diskSpoolBufferSizeMB="50"
|
|
|
+ timeToIdleSeconds="300"
|
|
|
+ timeToLiveSeconds="600"
|
|
|
+ maxElementsOnDisk="10000000"
|
|
|
+ diskExpiryThreadIntervalSeconds="120"
|
|
|
+ memoryStoreEvictionPolicy="LRU">
|
|
|
+
|
|
|
+ </defaultCache>
|
|
|
+
|
|
|
+ <cache name="problem"
|
|
|
+ maxElementsInMemory="100"
|
|
|
+ eternal="false"
|
|
|
+ timeToIdleSeconds="30"
|
|
|
+ timeToLiveSeconds="300"
|
|
|
+ memoryStoreEvictionPolicy="LRU"/>
|
|
|
+
|
|
|
+ <cache name="problemTestCase"
|
|
|
+ maxElementsInMemory="1000"
|
|
|
+ eternal="false"
|
|
|
+ timeToIdleSeconds="30"
|
|
|
+ timeToLiveSeconds="300"
|
|
|
+ memoryStoreEvictionPolicy="LRU"/>
|
|
|
+
|
|
|
+</ehcache>
|