Ehcache.xml文件配置官方

 

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <ehcache>  
  3. <!--  
  4.     DiskStore configuration  
  5.     =======================  
  6.   
  7.     The diskStore element is optional. To turn off disk store path creation, comment 
  8. out the diskStore element below.  
  9.   
  10.     Configure it if you have overflowToDisk or diskPersistent enabled for any cache.  
  11.   
  12.     If it is not configured, and a cache is created which requires a disk store,
  13.  a warning will be issued and java.io.tmpdir will automatically be used.  
  14.   
  15.     diskStore has only one attribute - "path". It is the path to the directory where
  16.  .data and .index files will be created.  
  17.   
  18.     If the path is one of the following Java System Property it is replaced by its 
  19. value in the running VM. For backward compatibility these should be specified without
  20.  being enclosed in the ${token} replacement syntax.  
  21.   
  22.     The following properties are translated:  
  23.     * user.home - User's home directory  
  24.     * user.dir - User's current working directory  
  25.     * java.io.tmpdir - Default temp file path  
  26.     * ehcache.disk.store.dir - A system property you would normally specify on the 
  27. command line  
  28.       e.g. java -Dehcache.disk.store.dir=/u01/myapp/diskdir ...  
  29.   
  30.     Subdirectories can be specified below the property e.g. java.io.tmpdir/one  
  31.     -->  
  32.     <diskStore path="java.io.tmpdir" />  
  33.   
  34. <!--  
  35.     Mandatory Default Cache configuration. These settings will be applied to 
  36. cachescreated programmtically using CacheManager.add(String cacheName).  
  37.   
  38.     The defaultCache has an implicit name "default" which is a reserved cache name.  
  39.     -->  
  40.     <defaultCache maxElementsInMemory="10000" eternal="false"  
  41.         timeToIdleSeconds="120" timeToLiveSeconds="120"  
  42.         overflowToDisk="true" diskPersistent="false"  
  43.         diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />  
  44.   
  45. <!--  
  46.     Cache configuration  
  47.     ===================  
  48.   
  49.     The following attributes are required.  
  50.   
  51.     name:  
  52.     Sets the name of the cache. This is used to identify the cache. It must be unique.  
  53.   
  54.     maxElementsInMemory:  
  55.     Sets the maximum number of objects that will be created in memory.  0 == no limit.  
  56.   
  57.     maxElementsOnDisk:  
  58.     Sets the maximum number of objects that will be maintained in the DiskStore  
  59.     The default value is zero, meaning unlimited.  
  60.   
  61.     eternal:  
  62.     Sets whether elements are eternal. If eternal,  timeouts are ignored and the  
  63.  element is never expired.  
  64.   
  65.     overflowToDisk:  
  66.     Sets whether elements can overflow to disk when the memory store has reached 
  67. the maxInMemory limit.  
  68.   
  69.     The following attributes and elements are optional.  
  70.   
  71.     timeToIdleSeconds:  
  72.     Sets the time to idle for an element before it expires.  
  73.     i.e. The maximum amount of time between accesses before an element expires  
  74.     Is only used if the element is not eternal.  
  75.     Optional attribute. A value of 0 means that an Element can idle for infinity.  
  76.     The default value is 0.  
  77.   
  78.     timeToLiveSeconds:  
  79.     Sets the time to live for an element before it expires.  
  80.     i.e. The maximum time between creation time and when an element expires.  
  81.     Is only used if the element is not eternal.  
  82.     Optional attribute. A value of 0 means that and Element can live for infinity.  
  83.     The default value is 0.  
  84.   
  85.     diskPersistent:  
  86.     Whether the disk store persists between restarts of the Virtual Machine.  
  87.     The default value is false.  
  88.   
  89.     diskExpiryThreadIntervalSeconds:  
  90.     The number of seconds between runs of the disk expiry thread. The default value 
  91. is 120 seconds.  
  92.   
  93.     diskSpoolBufferSizeMB:  
  94.     This is the size to allocate the DiskStore for a spool buffer. Writes are made to
  95.  this area and then asynchronously written to disk. The default size is 30MB.  
  96.     Each spool buffer is used only by its cache. If you get OutOfMemory errors 
  97. consider lowering this value. To improve DiskStore performance consider increasing it.
  98.  Trace level logging in the DiskStore will show if put back ups are occurring.  
  99.   
  100.     clearOnFlush:  
  101.     whether the MemoryStore should be cleared when flush() is called on the cache.  
  102.     By default, this is true i.e. the MemoryStore is cleared.  
  103.   
  104.     memoryStoreEvictionPolicy:  
  105.     Policy would be enforced upon reaching the maxElementsInMemory limit. Default  
  106.     policy is Least Recently Used (specified as LRU). Other policies available -  
  107.     First In First Out (specified as FIFO) and Less Frequently Used  
  108.     (specified as LFU)  
  109. -->  
  110.     <cache name="SimplePageCachingFilter" maxElementsInMemory="10000"  
  111.          eternal="false" overflowToDisk="false"   
  112.          timeToIdleSeconds="60"   
  113.         timeToLiveSeconds="120" memoryStoreEvictionPolicy="LFU" />  
  114. </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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值