記錄問題1:分佈式採用了rmi配置,可是配置後一直沒有做用,控制檯報如下警告:java
[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.spring
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.>apache
[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.>bootstrap
Station [WARN] 10:19:59 [main RMICacheManagerPeerListener:145] -tomcat
解決辦法:在spring中ehcache配置中須要增長屬性:property name="shared" value="true"socket
完成配置以下:分佈式
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:ehcache.xml" /> <property name="shared" value="true"/> </bean>
記錄問題二:ehcache.xml配置信息以下所示:ide
<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>