From: Michael Wallner Date: Tue, 20 Apr 2021 16:34:06 +0000 (+0200) Subject: bin/memslap: add ascii mget support X-Git-Tag: 1.1.0~14 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b74783f0513395a659f1b8cad12b1a6acad1503e;p=awesomized%2Flibmemcached bin/memslap: add ascii mget support --- diff --git a/src/bin/memslap.cc b/src/bin/memslap.cc index baf6df63..fb512268 100644 --- a/src/bin/memslap.cc +++ b/src/bin/memslap.cc @@ -117,13 +117,28 @@ static size_t execute_get(const client_options &opt, memcached_st &memc, const k static size_t execute_mget(const client_options &opt, memcached_st &memc, const keyval_st &kv) { size_t retrieved = 0; memcached_execute_fn cb[] = {&counter}; + memcached_return_t rc; - auto rc = memcached_mget_execute(&memc, kv.key.chr.data(), kv.key.len.data(), kv.num, cb, &retrieved, 1); + if (memcached_is_binary(&memc)) { + rc = memcached_mget_execute(&memc, kv.key.chr.data(), kv.key.len.data(), kv.num, cb, + &retrieved, 1); - while (rc != MEMCACHED_END && memcached_success(rc)) { - rc = memcached_fetch_execute(&memc, cb, &retrieved, 1); - } + while (rc != MEMCACHED_END && memcached_success(rc)) { + rc = memcached_fetch_execute(&memc, cb, &retrieved, 1); + } + } else { + memcached_result_st res; + memcached_result_create(&memc, &res); + + rc = memcached_mget(&memc, kv.key.chr.data(), kv.key.len.data(), kv.num); + while (rc != MEMCACHED_END && memcached_success(rc)) { + if (memcached_fetch_result(&memc, &res, &rc)) { + ++retrieved; + } + } + memcached_result_free(&res); + } if (memcached_fatal(rc)) { if (!opt.isset("quiet")) { std::cerr << "Failed mget: " << memcached_strerror(&memc, rc) << ": "