SSI开发:ehcache.xml标准配置模板

本文档提供了一个Ehcache的配置模板,详细解释了各配置项的作用,包括缓存的最大内存元素数、硬盘元素数、是否永久存储、溢出到硬盘策略等,并给出了具体的示例,如testCache、dictionaryCache和autoCompleteCache的配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
 monitoring="autodetect">

 <defaultCache maxElementsInMemory="10000" eternal="false"
  timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
  maxElementsOnDisk="10000000" diskPersistent="false"
  diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
  
  <!--  
       
        1.必须要有的属性:  
       
        name: cache的名字,用来识别不同的cache,必须惟一。  
       
        maxElementsInMemory: 内存管理的缓存元素数量最大限值。  
       
        maxElementsOnDisk: 硬盘管理的缓存元素数量最大限值。默认值为0,就是没有限制。  
       
        eternal: 设定元素是否持久话。若设为true,则缓存元素不会过期。  
       
        overflowToDisk: 设定是否在内存填满的时候把数据转到磁盘上。  
       
        2.下面是一些可选属性:  
       
        timeToIdleSeconds: 设定元素在过期前空闲状态的时间,只对非持久性缓存对象有效。默认值为0,值为0意味着元素可以闲置至无限长时间。  
       
        timeToLiveSeconds: 设定元素从创建到过期的时间。其他与timeToIdleSeconds类似。  
       
        diskPersistent: 设定在虚拟机重启时是否进行磁盘存储,默认为false.(我的直觉,对于安全小型应用,宜设为true)。  
       
        diskExpiryThreadIntervalSeconds: 访问磁盘线程活动时间。  
       
        diskSpoolBufferSizeMB: 存入磁盘时的缓冲区大小,默认30MB,每个缓存都有自己的缓冲区。  
       
        memoryStoreEvictionPolicy: 元素逐出缓存规则。共有三种,Recently Used (LRU)最近最少使用,为默认。
                                               First In First Out (FIFO),先进先出。Less Frequently Used(specified as LFU)最少使用 
       
    -->
  
 <cache name="testCache" maxElementsInMemory="10000"
  maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"
  diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"
  memoryStoreEvictionPolicy="LFU" />
  
 <cache name="dictionaryCache" maxElementsInMemory="10000"
  maxElementsOnDisk="1000" eternal="true" overflowToDisk="true"
  diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"
  memoryStoreEvictionPolicy="LFU" />
  
 <cache name="autoCompleteCache" maxElementsInMemory="10000"
  maxElementsOnDisk="1000" eternal="false" overflowToDisk="true"
  diskSpoolBufferSizeMB="20" timeToIdleSeconds="300" timeToLiveSeconds="600"
  memoryStoreEvictionPolicy="LFU" />
</ehcache> 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值