Jedis is powerful, but can not be specified as Nodejs read data from the slave, so that the volume of data read and write a large number of read and write separation, reduce the redis pressure.
We can use the method in Jedis to encapsulate a method similar to this.
GitHub Address: Https://github.com/candyleer/jedis-enhance
Use methods such as:
Specify the Mastername name, Sentinels address, and define a connection pool, after initialization can get a Jedis connection, support Sentinel Master switchover after re-election of the appropriate slave, if the current connection slave hangs, need to restart the service to connect (The Redis Sentinel automatic Master election will not be triggered at this time.)
<bean id="jedisSentinelPool" class="com.candy.cache.jedis.JedisSentinelPool"> <constructor-arg name="masterName" value="test"/> <constructor-arg name="sentinels" value="127.0.0.1:26279,127.0.0.1:36379" /> <constructor-arg name="poolConfig" ref="poolConfig" /> <constructor-arg name="role" value="slave" /> <constructor-arg name="timeout" value="5000" /></bean>
Jedis Support Sentinel Master-slave configuration role for slave