- <?xml version="1.0" encoding="UTF-8"?>
- <ehcache>
- <!--
- DiskStore configuration
- =======================
- The diskStore element is optional. To turn off disk store path creation, comment
- out the diskStore element below.
- Configure it if you have overflowToDisk or diskPersistent enabled for any cache.
- If it is not configured, and a cache is created which requires a disk store,
- a warning will be issued and java.io.tmpdir will automatically be used.
- diskStore has only one attribute - "path". It is the path to the directory where
- .data and .index files will be created.
- If the path is one of the following Java System Property it is replaced by its
- value in the running VM. For backward compatibility these should be specified without
- being enclosed in the ${token} replacement syntax.
- The following properties are translated:
- * user.home - User's home directory
- * user.dir - User's current working directory
- * java.io.tmpdir - Default temp file path
- * ehcache.disk.store.dir - A system property you would normally specify on the
- command line
- e.g. java -Dehcache.disk.store.dir=/u01/myapp/diskdir ...
- Subdirectories can be specified below the property e.g. java.io.tmpdir/one
- -->
- <diskStore path="java.io.tmpdir" />
- <!--
- Mandatory Default Cache configuration. These settings will be applied to
- cachescreated programmtically using CacheManager.add(String cacheName).
- The defaultCache has an implicit name "default" which is a reserved cache name.
- -->
- <defaultCache maxElementsInMemory="10000" eternal="false"
- timeToIdleSeconds="120" timeToLiveSeconds="120"
- overflowToDisk="true" diskPersistent="false"
- diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
- <!--
- Cache configuration
- ===================
- The following attributes are required.
- name:
- Sets the name of the cache. This is used to identify the cache. It must be unique.
- maxElementsInMemory:
- Sets the maximum number of objects that will be created in memory. 0 == no limit.
- maxElementsOnDisk:
- Sets the maximum number of objects that will be maintained in the DiskStore
- The default value is zero, meaning unlimited.
- eternal:
- Sets whether elements are eternal. If eternal, timeouts are ignored and the
- element is never expired.
- overflowToDisk:
- Sets whether elements can overflow to disk when the memory store has reached
- the maxInMemory limit.
- The following attributes and elements are optional.
- timeToIdleSeconds:
- Sets the time to idle for an element before it expires.
- i.e. The maximum amount of time between accesses before an element expires
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that an Element can idle for infinity.
- The default value is 0.
- timeToLiveSeconds:
- Sets the time to live for an element before it expires.
- i.e. The maximum time between creation time and when an element expires.
- Is only used if the element is not eternal.
- Optional attribute. A value of 0 means that and Element can live for infinity.
- The default value is 0.
- diskPersistent:
- Whether the disk store persists between restarts of the Virtual Machine.
- The default value is false.
- diskExpiryThreadIntervalSeconds:
- The number of seconds between runs of the disk expiry thread. The default value
- is 120 seconds.
- diskSpoolBufferSizeMB:
- This is the size to allocate the DiskStore for a spool buffer. Writes are made to
- this area and then asynchronously written to disk. The default size is 30MB.
- Each spool buffer is used only by its cache. If you get OutOfMemory errors
- consider lowering this value. To improve DiskStore performance consider increasing it.
- Trace level logging in the DiskStore will show if put back ups are occurring.
- clearOnFlush:
- whether the MemoryStore should be cleared when flush() is called on the cache.
- By default, this is true i.e. the MemoryStore is cleared.
- memoryStoreEvictionPolicy:
- Policy would be enforced upon reaching the maxElementsInMemory limit. Default
- policy is Least Recently Used (specified as LRU). Other policies available -
- First In First Out (specified as FIFO) and Less Frequently Used
- (specified as LFU)
- -->
- <cache name="SimplePageCachingFilter" maxElementsInMemory="10000"
- eternal="false" overflowToDisk="false"
- timeToIdleSeconds="60"
- timeToLiveSeconds="120" memoryStoreEvictionPolicy="LFU" />
- </ehcache>
<ehcache>
<!—设置缓存文件 .data 的创建路径。
如果该路径是 Java 系统参数,当前虚拟机会重新赋值。
下面的参数这样解释:
user.home – 用户主目录
user.dir – 用户当前工作目录
java.io.tmpdir – 默认临时文件路径 -->
<diskStore path="java.io.tmpdir"/>
<!—缺省缓存配置。CacheManager 会把这些配置应用到程序中。
下列属性是 defaultCache 必须的:
maxElementsInMemory - 设定内存中创建对象的最大值。
eternal - 设置元素(内存中对象)是否永久驻留。如果是,将忽略超时限制且元素永不消亡。
timeToIdleSeconds - 设置某个元素消亡前的停顿时间。
也就是在一个元素消亡之前,两次访问时间的最大时间间隔值。
这只能在元素不是永久驻留时有效(译注:如果对象永恒不灭,则设置该属性也无用
如果该值是 0 就意味着元素可以停顿无穷长的时间。
timeToLiveSeconds - 为元素设置消亡前的生存时间。
也就是一个元素从构建到消亡的最大时间间隔值。
这只能在元素不是永久驻留时有效。
overflowToDisk - 设置当内存中缓存达到 maxInMemory 限制时元素是否可写到磁盘上。
-->
<cache name="org.taha.cache.METHOD_CACHE"
maxElementsInMemory="300"
eternal="false"
timeToIdleSeconds="500"
timeToLiveSeconds="500"
overflowToDisk="true"
/>
</ehcache>