cpp_redis
cpp_redis copied to clipboard
blpop command still block program after timeout
I try to use blpop with timeout parameter as the following code:
int main(int argc, char* argv[]) {
cpp_redis::client client;
RedisInfo redis_info;
redis_info.address = "127.0.0.1";
redis_info.port = 6379;
// This function is just init a redis client.
if (!common::InitRedisClient(&client, redis_info)) {
cout << "Establish connection to redis failed" << endl;
return 0;
} else {
cout << "Establish connection to redis succeed" << endl;
}
vector<string> keys;
keys.push_back("test");
client.blpop(keys, 1, [](cpp_redis::reply& reply) {
cout << "Blpop response: " << reply.as_string() << endl;
});
client.sync_commit();
cout << "Blpop timeout" << endl;
return 0;
}
As my understanding, program should print "Blpop timeout" after 1s and there are no data push to test list. But program seem to be block and never end.
Is this expected behavior of blpop command with timeout?