Redis的sentinel使用及spring集成

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以上

相关推荐