JedisCluster连接关闭问题
set方法为例
//伪代码
JedisCluster jedisCluster = new JedisCluster();
jedisCluster.set("testKey", "testValue");
进入到set方法
类JedisCluster中;
初始化一个JedisClusterCommand对象,调用run方法;
需要实现一个execute方法,通过Jedis调用set方法(这里又回到单节点调用set的方式了);
public String set(final String key, final String value) {
return new JedisClusterCommand(connectionHandler, maxAttempts) {
@Override
public String execute(Jedis connection) {
return connection.set(key, value);
}
}.run(key);
}
进入到run方法
类JedisClusterCommand中;
public T run(String key) {
return runWithRetries(JedisClusterCRC16.getSlot(key), this.maxAttempts, false, null);
}
进入到runWithRetries方法
类JedisClusterCommand中;