首页 > 解决方案 > ehcache 和 spring-boot 中的复制缓存

问题描述

ehcache 版本 2.8.3 正在 spring-boot 中使用。待测试的服务器是基于linux的服务器A和服务器B缓存共有三种下面是ehcache.xml的配置。

<ehcache> 
    <diskStore path="java.io.tmpdir" /> 

    <cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" 
        properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=40001, 
        timeToLive=1 ,replicatePuts=true,replicatePutsViaCopy=true ,replicateUpdates=true ,replicateUpdatesViaCopy=false,
        replicateRemovals=true ,replicateAsynchronously=false"/> 

    <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
        properties="socketTimeoutMillis=2000, port=40001"/> 
    <cache name="aCache" 
            maxElementsInMemory="0" 
            eternal="true" 
            timeToIdleSeconds="0" 
            timeToLiveSeconds="0" 
            overflowToDisk="false"> 

        <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/> 

        <bootstrapCacheLoaderFactory
                class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
                properties="bootstrapAsynchronously=true"
                propertySeparator="," />    
        <!-- <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" 
                properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, 
                replicateUpdatesViaCopy=false, replicateRemovals=true"/> --> 
    </cache> 

    <cache name="bCache" 
            maxElementsInMemory="0" 
            eternal="true" 
            timeToIdleSeconds="0" 
            timeToLiveSeconds="0" 
            overflowToDisk="false"> 

        <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>

        <bootstrapCacheLoaderFactory
                class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
                properties="bootstrapAsynchronously=true"
                propertySeparator="," /> 
    </cache> 

    <cache name="cCache" 
            maxElementsInMemory="0" 
            eternal="true" 
            timeToIdleSeconds="0" 
            timeToLiveSeconds="0" 
            overflowToDisk="false"> 

        <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>

        <bootstrapCacheLoaderFactory
                class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
                properties="bootstrapAsynchronously=true"
                propertySeparator="," />
    </cache> 
</ehcache> 

服务器 A 和服务器 B 上的 Ehcache.xml 使用相同的设置输入。当我在服务器 A 上添加缓存时,我想查看在服务器 B 上添加的缓存

只会显示以下日志,但服务器 B 无法检查添加的缓存。

[组播心跳接收线程] DEBUG nsedMulticastKeepaliveHeartbeatReceiver - rmiUrls 收到 //192.168.10.20:40001/aCache|//192.168.10.20:40001/bCache|//192.168.10.20:40001/cCache

如果你知道怎么做,请告诉我。

标签: spring-bootehcachereplicate

解决方案


推荐阅读