Closed dkd1111 closed 2 years ago
@dkd1111 There's no need to do the change, instead, reply::parse
can handle scan result with a proper template type. You can try the following code for how to do scan with async interface.
void scan(AsyncRedis &r, long long cursor = 0) {
using ScanResult = std::pair<std::string, std::vector<std::string>>;
r.command<ScanResult>("scan", cursor, [&r](Future<ScanResult> &&fut) {
try {
auto res = fut.get();
const auto &keys = res.second;
// process scan results.
auto next_cursor = std::stoll(res.first); // Redis return cursor as a string, instead of an integer.
if (next_cursor != 0) {
scan(r, next_cursor);
}
} catch (const Error &e) {
// handle error
}
});
}
B.T.W. Thanks for the pull request :)
Regards
I see, thanks for comments. :)
AsyncRedis doesn't support "scan" command. Its redisReply should be checked recusively if array type.