ehcache有几种方式实现集群:rmi、jgroup、jms,这里讲一下ehcache使用rmi的实现方式。
主要有三个配置:
1、cacheManagerPeerProviderFactory配置:
<cacheManagerPeerProviderFactory
class= “net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory”
properties= “peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446, timeToLive=1”/>
timeToLive的值指的是数据包可以传递的域或是范围。约定如下:
0是限制在同一个服务器
1是限制在同一个子网(默认)
32是限制在同一个网站
64是限制在同一个region
128是限制在同一个大洲
255是不限制
2、cacheManagerPeerListenerFactory配置:
<cacheManagerPeerListenerFactory
class= “net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory”
properties= “hostName=192.168.1.101, port=40001, socketTimeoutMillis=2000”/></