use*_*742 5 java caching hibernate ehcache cluster-computing
在我的基于 Spring MVC + Hibernate 的 Web 应用程序中,我使用 Ehcache 作为 Hibernate 二级缓存。它在单个服务器上运行得很好。但是我需要将我的应用程序迁移到集群环境。只是想知道如何使 Ehcache 作为 Hibernate 的二级缓存在集群环境中工作?提前致谢。
您需要使用 Teracotta 来集群 Ehcache,并将您的ehcache.xml
配置更改为能够感知集群环境的male Ehcache:
<cache name="cacheRegion"
maxEntriesLocalHeap="1000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="1800"">
<persistence strategy="distributed"/>
<terracotta clustered="true" consistency="eventual" />
</cache>
Run Code Online (Sandbox Code Playgroud)
如果您不想购买 Teracotta 许可证,则可以设置复制缓存。您可以使用RMI 复制来协调 Cache 节点:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
multicastGroupPort=4446, timeToLive=32"/>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3691 次 |
最近记录: |