简体   繁体   中英

Modifying EHCache beans defined in Spring

Assuming the belowcache definition in Spring, is it possible to set bootstrapCacheLoaderFactory and cacheEventListenerFactory through a separate ehcache.xml file or in the same xml file? If we set them in the Cache definitions in ehcache.xml, which cache definitions(in the current xml file or ehcache.xml ?!) will be applied?

Where can I set cacheManagerPeerProviderFactory and cacheManagerPeerListenerFactory for CacheManager?

    <bean id="reportCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean">
        <property name="cacheManager" ref="cacheManager"/>
        <property name="maxElementsInMemory" value="${cache.report.maxMemoryElements}"/>
      </bean> 

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
  <property name="configLocation" value="WEB-INF/ehcache.xml"/>

  </bean>

Would the below tag in ehcache.xml work?

 <cache name="reporteCache">
    <bootstrapCacheLoaderFactory class = "net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties = "bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000"/>

            <cacheEventListenerFactory class = "net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, asynchronousReplicationIntervalMillis=100"/>

       </cache>

Both of the xml and java code would be fine.

Thank you in advance.

Just in case someone else is reading this? You can set the cacheManagerPeerListenerFactory in your ehcache.xml file as follows

<cacheManagerPeerProviderFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
        properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.2,
                multicastGroupPort=4455, timeToLive=1"/>
<cacheManagerPeerListenerFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="host=hostname,port=40001, socketTimeoutMillis=2000"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM