Closed dxq174510447 closed 3 years ago
i replace redis library using redis-plus-plus ,it is ok
You use get() function on the same future object twice, which is not allowed.
cpp_redis::client client;
client.connect("127.0.0.1", 6379);
client.auth("123456");
std::future<cpp_redis::reply> r2= client.get("hello");
client.sync_commit();
if(r2.get().is_null()){ /*Here*/
cout << "null" << endl;
}
else{
cout << "123" << endl;
cout << r2.get().as_string()<< endl; /*And here*/
cout << "456" << endl;
}
Consider use temporary variable like this:
cpp_redis::client client;
client.connect("127.0.0.1", 6379);
client.auth("123456");
std::future<cpp_redis::reply> r2= client.get("hello");
client.sync_commit();
auto r2_result = r2.get();
if(r2_result.is_null()){
cout << "null" << endl;
}
else{
cout << "123" << endl;
cout << r2_result.as_string()<< endl;
cout << "456" << endl;
}
Describe the bug A clear and concise description of what the bug is. i use bazel compile my project. below is my code
WORKSPACE
BUILD
build
run
console not print the value of 'hello' and '456'
what cause the problem?