我在群集中有两个tomcat服务器,我想复制群集中的缓存(每个服务器中的缓存相同)。我如何使用以下配置使用Ehcache和JGroups / RMI(不定义缓存):
1.Context配置:
<bean id="myEhCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:my-ehcache.xml"/>
</bean>
2.Controller:
@Controller
public class MyUniqueService {
@Resource(name="myEhCacheManager")
private CacheManager cacheManager;
...
}
这里提到了这个配置: Getting an EhCache instance with Spring... intelligently
非常感谢
答案 0 :(得分:0)
要复制其他服务器上的缓存,配置可以如下:
<ehcache>
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual, rmiUrls=${other sharinr server cache url}"/>
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost,port=xxx, remoteObjectPort=xxx, socketTimeoutMillis=2000"/>
<cache name="MY_CACHE"
maxEntriesLocalHeap=""
eternal="false"
timeToIdleSeconds=""
timeToLiveSeconds=""
maxEntriesLocalDisk=""
diskExpiryThreadIntervalSeconds=""
memoryStoreEvictionPolicy="LRU">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
</ehcache>