EhCache缓存共享

直接上代码,修改ehcache 的配置文件:
<?xml version="1.0" encoding="utf-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
		 xsi:noNamespaceSchemaLocation="ehcache.xsd">
    <diskStore path="java.io.tmpdir"/>

	<cacheManagerPeerProviderFactory   
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"   
            properties="hostName=127.0.0.1,  
            port=2000,  
            socketTimeoutMillis=12000,  
            peerDiscovery=manual,  
            rmiUrls=//101.1.93.8:1000/gscMisRegCache|//101.1.93.8:1000/ApproveTypeCache"  
     />   
	 	  			
	<cacheManagerPeerListenerFactory  
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"  
        properties="hostName=127.0.0.1,port=2000,socketTimeoutMillis=120000" />
 
    <defaultCache maxElementsInMemory="10000" 
    			  eternal="false" 
    			  timeToIdleSeconds="30" 
    			  timeToLiveSeconds="30" 
    			  overflowToDisk="false"/>
    <!-- 
        配置自定义缓存
        maxElementsInMemory:缓存中允许创建的最大对象数</cache>
        eternal:缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期。
        timeToIdleSeconds:缓存数据的钝化时间,也就是在一个元素消亡之前,
                    两次访问时间的最大时间间隔值,这只能在元素不是永久驻留时有效,
                    如果该值是 0 就意味着元素可以停顿无穷长的时间。
        timeToLiveSeconds:缓存数据的生存时间,也就是一个元素从构建到消亡的最大时间间隔值,
                    这只能在元素不是永久驻留时有效,如果该值是0就意味着元素可以停顿无穷长的时间。
        overflowToDisk:内存不足时,是否启用磁盘缓存。
        memoryStoreEvictionPolicy:缓存满了之后的淘汰算法。
    -->
      
     <!-- 部门信息缓存 -->
	<cache name="deptListCache"
        maxElementsInMemory="10000"
        eternal="false"
        overflowToDisk="true"
        timeToIdleSeconds="2628000"
        timeToLiveSeconds="2628000"
        memoryStoreEvictionPolicy="LFU" > 
		
	</cache>

        
       <!-- 地域信息缓存 -->
	<cache name="gscMisRegCache"
        maxElementsInMemory="10000"
        eternal="false"
        overflowToDisk="true"
        timeToIdleSeconds="28800"
        timeToLiveSeconds="50400"
        memoryStoreEvictionPolicy="LFU" > 
		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" />  
		<!-- 用于在初始化缓存,以及自动设置 -->  
		<bootstrapCacheLoaderFactory  class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />		
	</cache>		        
        
 <!-- 2018-05-24 事项类别缓存 (该缓存存活24个小时)-->
	<cache name="ApproveTypeCache"
        maxElementsInMemory="10000"
        eternal="false"
        overflowToDisk="true"
        timeToIdleSeconds="28800"
        timeToLiveSeconds="86400"
        memoryStoreEvictionPolicy="LFU" > 
 		<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" />  
        <!-- 用于在初始化缓存,以及自动设置 -->  
        <bootstrapCacheLoaderFactory  class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />      
	</cache>		
	
</ehcache>

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值