sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.6k stars 347 forks source link

[BUG] asyncRedis hmget command no instance of overloaded function #487

Closed conde2 closed 1 year ago

conde2 commented 1 year ago

Describe the bug I always receive compiling errors while trying to use the hmget command with asyncRedis

To Reproduce

            std::vector<std::string> fields= {"k1", "k2", "k3"};
            asyncRedis->hmget("hash", fields.begin(), fields.end());
            asyncRedis->hmget("hash", {"field1", "field2"});

Expected behavior Be able to use hmget command with asyncRedis

Environment:

sewenew commented 1 year ago

AsyncRedis::hmget is a template method, you should specify a template parameter, i.e. the type of hmget's result:

auto vals = r.hmget<vector<OptionalString>>("key", {"k", "k1"}).get();
for (auto &val : vals) {
        if (val)
            cout << *val << endl;
        else
            cout << "not exist" << endl;
}

Regards

conde2 commented 1 year ago

Thank you, it was not stated on the documentation so I thought it was the same as the sync version.