EhCache 分布式缓存/缓存集群

姚春来 发布于 2014/02/11 16:35
阅读 1K+
收藏 2

配置EhCache缓存集群,有A,B服务器,同时启动服务器,A服务器缓存可以同步到B服务器,而B服务器换成不能同步到A服务器:下面是xml

 A服务器:

<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=32"/>


<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" properties="hostName=10.10.7.231, port=40001,socketTimeoutMillis=2000" />


<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU">
</defaultCache>

<!-- Special objects setting. -->

<cache name="com.dsideal.modules.sys.entity.Dict" maxEntriesLocalHeap="1000" eternal="false" overflowToDisk="true" maxEntriesLocalDisk="100000" memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"  />
</cache>


B服务器:

<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=32"/>


<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" properties="hostName=10.10.7.103, port=40001,socketTimeoutMillis=2000" />


<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true" diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU">
</defaultCache>




<!-- Special objects setting. -->
<cache name="com.dsideal.modules.sys.entity.Dict" maxEntriesLocalHeap="1000" eternal="false" overflowToDisk="true" maxEntriesLocalDisk="100000" memoryStoreEvictionPolicy="LFU"
transactionalMode="off">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"  />
</cache>

加载中
0
红薯
红薯

https://www.ibm.com/developerworks/cn/java/j-lo-ehcache/

Ehcache 有几种集群的方案,包括 RMI 和 JGroups。我的这篇文章里都有详细介绍哦:)

红薯
红薯
回复 @姚春来 : 我的文章只讲技术思路,不提具体应用场景,其实是差不多的
姚春来
姚春来
谢谢红薯 我要问的问题不是这个,是shiro+ehcache RMI 共享sesison
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部