关于spring集成ehcache做分布式的问题记录

记录问题1:分布式采用了rmi配置,但是配置后一直没有作用,控制台报以下警告:

[WARN] 10:19:59 [main CacheManager:292] -
The source of the configuration was classpath.
The diskStore path for this CacheManager will be set to C:\apache-tomcat-5.5.16\temp\ehcache_auto_created_1168453199935.

To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a
separate ehcache configuration (ehcache.xml) for each CacheManager instance.>

[WARN] 10:19:59 [main CacheManager:319] -
The resource is RMI listener port: 40001.
Attempting automatic resolution. The source of the configuration was classpath.
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a
separate ehcache configuration (ehcache.xml) for each CacheManager instance.>

Station [WARN] 10:19:59 [main RMICacheManagerPeerListener:145] -

 

解决办法:在spring中ehcache配置中需要增加属性:property name="shared" value="true"

完成配置如下:

 

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
		<property name="configLocation" value="classpath:ehcache.xml" />
		<property name="shared" value="true"/>
	</bean>

记录问题二:ehcache.xml配置信息如下所示:

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
    <diskStore path="java.io.tmpdir"/>
   
    <defaultCache
            maxElementsInMemory="10000"
            eternal="false"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskPersistent="false"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
            />
			
  
    <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
       properties="peerDiscovery=manual,
	   rmiUrls=//10.4.7.194:40001/CodeCache|//10.4.7.194:40001/UsersDataCache" />

   
  <cacheManagerPeerListenerFactory  
	class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
	properties="hostName=10.4.7.193,port=40001, socketTimeoutMillis=2000"/>    
			
    <cache name="CodeCache"
           maxElementsInMemory="10000"
           eternal="false"
           overflowToDisk="true"
           timeToIdleSeconds="300"
           timeToLiveSeconds="600"
           memoryStoreEvictionPolicy="LFU"
           >
			<cacheEventListenerFactory  
				class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" 
				properties="replicateAsynchronously=true,
				replicatePuts=true,
				replicateUpdates=true,
				replicateUpdatesViaCopy=true,
				replicateRemovals=true"/> 
			<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
    </cache>				
            
    	
            
     <cache name="UsersDataCache"
           maxElementsInMemory="20000"
           eternal="false"
           overflowToDisk="true"
           timeToIdleSeconds="300"
           timeToLiveSeconds="600"
           memoryStoreEvictionPolicy="LFU"
            >
			<cacheEventListenerFactory  
				class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" 
				properties="replicateAsynchronously=true,
				replicatePuts=true,
				replicateUpdates=true,
				replicateUpdatesViaCopy=true,
				replicateRemovals=true"/> 
			<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
    </cache>	
            
</ehcache>


   
     
           
 

转载于:https://my.oschina.net/u/216368/blog/818356

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值