ehcache.xml例子

<?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" dynamicConfig="true">
       
        <diskStore path="java.io.tmpdir/ehcache-wisdom" />
       
        <!-- 设置自身 -->
       
    <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"  
       properties="hostName=127.0.0.1,port=40001,socketTimeoutMillis=2000" />
       
       
        <!-- |//192.168.1.其他集群服务器IP:40002/security_resource"/> -->
       
        <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
                      properties="peerDiscovery=manual,
                      rmiUrls=//127.0.0.1:40002/security_resource"/>
                     
       
        <!-- <defaultCache maxElementsInMemory="内存对象数量" overflowToDisk="内存满后是否存磁盘" eternal="对象永不过期"
                memoryStoreEvictionPolicy="LRU优先清除不经常使用的对象" maxElementsOnDisk="磁盘对象数量" diskExpiryThreadIntervalSeconds="访问磁盘线程活动时间"
                timeToIdleSeconds="清理多少秒不使用的对象" timeToLiveSeconds="清理创建多少秒的对象" diskPersistent="重启内存对象持久化入磁盘" /> -->
       
        <defaultCache maxElementsInMemory="10000" overflowToDisk="true" eternal="false"
                memoryStoreEvictionPolicy="LRU" maxElementsOnDisk="10000000" diskExpiryThreadIntervalSeconds="600"
                timeToIdleSeconds="3600" timeToLiveSeconds="100000" diskPersistent="false">
                <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" />    
        </defaultCache>
       
       
        <!-- replicateAsynchronously对象同步是否异步完成,默认为true。如果比较紧急就设为false。
                                                                在一致性时间性要求不强的时候,设为异步可大大提供性能,因为它是异步立即返回的,而且可以批量提交。
                replicateUpdatesViaCopy 是否将对象变更复制到所有节点,还是只是发送一个失效信息,让对方该缓存失效,当对方需要该缓存时重新计算载入。
                                                                默认为true。鉴于对象复制的消耗挺大的,又有锁的问题,而且对方也未必需要该对象,所以此属性建议设为false。
                                                                如果业务上真的需要设为true时,就可考虑使用Terracotta了。
                replicatePuts、replicateUpdates、replicateRemovals增删改是否同步,默认都为true。但因为我们前面选择了失效算法,
                                        所以replicatePuts要设为false。 -->

        <cache name="security_resource" maxElementsInMemory="500" eternal="true" overflowToDisk="true">  
        <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
        properties="replicateAsynchronously=true,replicateUpdatesViaCopy=false,
                                replicatePuts=false,replicateUpdates=false,replicateRemovals=false"/>  
    </cache>

        <cache name="task_scheduled" maxElementsInMemory="50" eternal="true" overflowToDisk="true"/>  

        <cache name="logger_cache" maxElementsInMemory="1000" eternal="true" overflowToDisk="true"/>  

        <cache name="jdbc_cache" maxElementsInMemory="1000" eternal="true" overflowToDisk="true"/>  

        <cache name="online_user_cache" maxElementsInMemory="200" eternal="true" overflowToDisk="true"/>  
       
</ehcache>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值