vipshop / hiredis-vip

Support redis cluster. Maintained and used at vipshop.
BSD 3-Clause "New" or "Revised" License
322 stars 173 forks source link

After calling redisClusterSetOptionParseSlaves, hiredis-vip still does not read the slave, only reads data from the master node. #121

Open sherwinl1u opened 5 years ago

sherwinl1u commented 5 years ago

RedisClusterSetOptionParseSlaves was called before the connection, but the actual test still does not connect to the slave node, what additional work is needed.

The connection code is roughly as follows: int main(){ cc_ = redisClusterContextInit();

redisClusterSetOptionAddNodes(cc_, hostlist_.c_str());
redisClusterSetOptionRouteUseSlots(cc_);
redisClusterSetOptionParseSlaves(cc_);

redisClusterConnect2(cc_);
if (cc_ == NULL || cc_->err)
{
    printf("Connect redis cluster fail, addr[%s], err[%s]",
                                hostlist_.c_str(),  cc_ == NULL ? "NULL" : cc_->errstr);
    return -1;
}

///do read wrok }