diff --git a/src/sw/redis++/async_redis.h b/src/sw/redis++/async_redis.h index 211c0c6..425fdc3 100644 --- a/src/sw/redis++/async_redis.h +++ b/src/sw/redis++/async_redis.h @@ -407,6 +407,14 @@ class AsyncRedis { Future mset(std::initializer_list il) { return mset(il.begin(), il.end()); } + + template + auto mset(Input first, Input last, Callback &&cb) + -> typename std::enable_if::type, Future &&>::value, void>::type { + range_check("MSET", first, last); + + _callback_fmt_command(std::forward(cb), fmt::mset, first, last); + } template Future msetnx(Input first, Input last) { diff --git a/src/sw/redis++/async_redis_cluster.h b/src/sw/redis++/async_redis_cluster.h index f640d1f..650d986 100644 --- a/src/sw/redis++/async_redis_cluster.h +++ b/src/sw/redis++/async_redis_cluster.h @@ -282,6 +282,14 @@ class AsyncRedisCluster { return mset(il.begin(), il.end()); } + template + auto mset(Input first, Input last, Callback &&cb) + -> typename std::enable_if::type, Future &&>::value, void>::type { + range_check("MSET", first, last); + + _callback_fmt_command(std::forward(cb), fmt::mset, first, last); + } + template Future msetnx(Input first, Input last) { range_check("MSETNX", first, last); diff --git a/test/src/sw/redis++/async_test.h b/test/src/sw/redis++/async_test.h index d40d047..0a2f302 100644 --- a/test/src/sw/redis++/async_test.h +++ b/test/src/sw/redis++/async_test.h @@ -199,6 +199,13 @@ void AsyncTest::_test_hash() { this->set_ready(); }); _wait(); + + set_ready(false); + std::map mkeys = {{test_key("str")+"1", "val1"}, {test_key("str")+"2", "val2"}}; + _redis.mset(mkeys.begin(), mkeys.end(), [this](Future &&fut) { + this->set_ready(); + }); + _wait(); } template