Java 将ehcache从一台服务器复制到另一台服务器
我有一个带有ehcache的tomcat服务器。我还有第二个带servlet的tomcat。当第二个servlet被初始化时,它应该从#1获取ehcache,并将所有数据放入其缓存 ehcache中是否有内置的“启动时复制”机制?或者如何获取序列化的ehcache数据,然后将其反序列化到ehcache。我知道我可以一个接一个地读取所有键,然后读取它们的所有值,然后序列化,但也许有更好的方法Java 将ehcache从一台服务器复制到另一台服务器,java,ehcache,Java,Ehcache,我有一个带有ehcache的tomcat服务器。我还有第二个带servlet的tomcat。当第二个servlet被初始化时,它应该从#1获取ehcache,并将所有数据放入其缓存 ehcache中是否有内置的“启动时复制”机制?或者如何获取序列化的ehcache数据,然后将其反序列化到ehcache。我知道我可以一个接一个地读取所有键,然后读取它们的所有值,然后序列化,但也许有更好的方法 谢谢对于您的要求,没有现成的支持 备选方案包括: Ehcache集群 Ehcache 请注意,两者之间
谢谢对于您的要求,没有现成的支持 备选方案包括:
- Ehcache集群
- Ehcache
免责声明:我在Ehcache上为Terracotta工作对于您的要求,没有现成的支持 备选方案包括:
- Ehcache集群
- Ehcache
免责声明:我在Ehcache上为Terracotta工作以下是我使用内置rmi复制解决方案的解决方案: 主配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost, port=40001,
socketTimeoutMillis=2000"/>
<cache name="masterCache"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=false, replicateUpdates=false,
replicateUpdatesViaCopy=false, replicateRemovals=false "/>
<persistence strategy="none"/>
</cache>
在这里,我为从机启用RMI侦听器,并为缓存启用RMI,但没有任何复制,因为我只需要从机启动时的数据,仅此而已
从配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//localhost:40001/masterCache"/>
<cache name="masterCache"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=false"/>
<persistence strategy="none"/>
</cache>
我将RMI连接到主节点并打开缓存的引导 以下是我使用内置rmi复制解决方案的解决方案: 主配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=localhost, port=40001,
socketTimeoutMillis=2000"/>
<cache name="masterCache"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=false, replicateUpdates=false,
replicateUpdatesViaCopy=false, replicateRemovals=false "/>
<persistence strategy="none"/>
</cache>
在这里,我为从机启用RMI侦听器,并为缓存启用RMI,但没有任何复制,因为我只需要从机启动时的数据,仅此而已
从配置:
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true"
monitoring="autodetect"
dynamicConfig="true">
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//localhost:40001/masterCache"/>
<cache name="masterCache"
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
properties="bootstrapAsynchronously=false"/>
<persistence strategy="none"/>
</cache>
我将RMI连接到主节点并打开缓存的引导 你看了吗?你看了吗?