1 <??> 2 <ehcache ="http://www.w3.org/2001/ xsi:noNamespaceSchemaLocation="ehcache.xsd"> 3 <!-- 缓存设置为磁盘缓存,防止重启tomcat时,app要重新登录 --> 4 <diskStore path="java.io.tmpdir"/> 5 <!-- 集群多台服务器中的缓存 6 注意每台要同步缓存的服务器的RMI通信socket端口都不一样,在配置的时候注意设置--> 7 <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 8 properties="hostName=10.1.35.111, port=40001,socketTimeoutMillis=2000"/> 9 <!---->10 <cacheManagerPeerProviderFactory 11 class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" 12 properties="peerDiscovery=manual,13 hostName=10.1.35.111,14 port=40002,15 rmiUrls=//10.1.35.111:40001/BaseDataCache|//10.1.35.111:40002/BaseDataCache,16 timeToLive=0"17 />18 <!--19 <cacheManagerPeerProviderFactory 20 21 properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, 22 multicastGroupPort=4446, timeToLive=32"/> 23 -->24 <!--25 搜索某个网段上的缓存:timeToLive26 0是限制在同一个服务器,1是限制在同一个子网, 32是限制在同一个网站27 ,64是限制在同一个region,128是限制在同一个大洲, 255是不限制 -->28 29 <defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="600" timeToLiveSeconds="86400" overflowToDisk="false"/>30 <!-- 31 配置自定义缓存32 maxElementsInMemory:缓存中允许创建的最大对象数33 eternal:缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期。34 timeToIdleSeconds:缓存数据的钝化时间,也就是在一个元素消亡之前,35 两次访问时间的最大时间间隔值,这只能在元素不是永久驻留时有效,36 如果该值是 0 就意味着元素可以停顿无穷长的时间。37 timeToLiveSeconds:缓存数据的生存时间,也就是一个元素从构建到消亡的最大时间间隔值,38 这只能在元素不是永久驻留时有效,如果该值是0就意味着元素可以停顿无穷长的时间。39 overflowToDisk:内存不足时,是否启用磁盘缓存。40 memoryStoreEvictionPolicy:缓存满了之后的淘汰算法。41 --> 42 <cache name="BaseDataCache"43 maxElementsInMemory="10000"44 eternal="false"45 overflowToDisk="true"46 timeToIdleSeconds="60000"47 timeToLiveSeconds="600000"48 memoryStoreEvictionPolicy="LFU">49 <!-- 50 RMI缓存分布同步查找 class使用net.sf.ehcache.distribution.RMICacheReplicatorFactory51 这个工厂支持以下属性:52 replicatePuts=true | false – 当一个新元素增加到缓存中的时候是否要复制到其他的peers。默认是true。53 replicateUpdates=true | false – 当一个已经在缓存中存在的元素被覆盖时是否要进行复制。默认是true。54 replicateRemovals= true | false – 当元素移除的时候是否进行复制。默认是true。55 replicateAsynchronously=true | false – 复制方式是异步的指定为true时,还是同步的,指定为false时。默认是true。56 replicatePutsViaCopy=true | false – 当一个新增元素被拷贝到其他的cache中时是否进行复制指定为true时为复制,默认是true。57 replicateUpdatesViaCopy=true | false – 当一个元素被拷贝到其他的cache中时是否进行复制指定为true时为复制,默认是true。58 asynchronousReplicationIntervalMillis=100059 -->60 <!-- 监听RMI同步缓存对象配置 注册相应的的缓存监听类,用于处理缓存事件,如put,remove,update,和expire -->61 <cacheEventListenerFactory62 class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"63 properties="replicateAsynchronously=true, 64 replicatePuts=true, 65 replicatePutsViaCopy=true,66 replicateUpdates=true,67 replicateUpdatesViaCopy=true, 68 replicateRemovals=true "/>69 </cache>70 71 </ehcache>
原标题:ehcache.xml 分布试缓存
关键词:xml