Spring 配置:
<bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig"> <property name="maxTotal" value="200" /> <property name="maxIdle" value="30" /> <property name="maxWaitMillis" value="30000" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="true" /> </bean> <bean id="jedisPool" class="redis.clients.jedis.JedisSentinelPool"> <constructor-arg index="0" value="mymaster" /> <constructor-arg index="1"> <set> <value>127.0.0.1:26379</value> <value>127.0.0.1:36379</value><!--配置了两个哨兵 --> </set> </constructor-arg> <constructor-arg index="2" ref="jedisPoolConfig" /> </bean> Jedis版本2.2.2以上
本文介绍了如何使用Spring框架配置Redis哨兵集群。具体包括设置最大连接数、空闲连接数、等待时间等参数,并通过构造JedisSentinelPool实例连接到带有两个哨兵节点的Redis集群。
1399

被折叠的 条评论
为什么被折叠?



