diff --git a/includes/cpp_redis/core/client.hpp b/includes/cpp_redis/core/client.hpp index 67ea6331..50583b03 100644 --- a/includes/cpp_redis/core/client.hpp +++ b/includes/cpp_redis/core/client.hpp @@ -513,6 +513,18 @@ namespace cpp_redis { std::future brpoplpush(const std::string &src, const std::string &dst, int timeout); + client& bzpopmin(const std::vector& keys, int timeout, const reply_callback_t& reply_callback); + + std::future bzpopmin(const std::vector& keys, int timeout); + + client& bzpopmax(const std::vector& keys, int timeout, const reply_callback_t& reply_callback); + + std::future bzpopmax(const std::vector& keys, int timeout); + + client& client_id(const reply_callback_t& reply_callback); + + std::future client_id(); + // template client &client_kill(const std::string &host, int port, const T &arg, const Ts &... args); @@ -549,6 +561,12 @@ namespace cpp_redis { std::future client_setname(const std::string &name); // + client& client_unblock(int id, const reply_callback_t& reply_callback); + + client& client_unblock(int id, bool witherror, const reply_callback_t& reply_callback); + + std::future client_unblock(int id, bool witherror = false); + client &cluster_addslots(const std::vector &p_slots, const reply_callback_t &reply_callback); std::future cluster_addslots(const std::vector &p_slots); @@ -1690,6 +1708,14 @@ namespace cpp_redis { std::future zlexcount(const std::string &key, const std::string &min, const std::string &max); + client& zpopmin(const std::string& key, int count, const reply_callback_t& reply_callback); + + std::future zpopmin(const std::string& key, int count); + + client& zpopmax(const std::string& key, int count, const reply_callback_t& reply_callback); + + std::future zpopmax(const std::string& key, int count); + client &zrange(const std::string &key, int start, int stop, const reply_callback_t &reply_callback); client & diff --git a/sources/core/client.cpp b/sources/core/client.cpp index 3383882f..776c20b8 100644 --- a/sources/core/client.cpp +++ b/sources/core/client.cpp @@ -623,6 +623,30 @@ namespace cpp_redis { return *this; } + client& + client::bzpopmin(const std::vector& keys, int timeout, const reply_callback_t& reply_callback) { + std::vector cmd = {"BZPOPMIN"}; + cmd.insert(cmd.end(), keys.begin(), keys.end()); + cmd.push_back(std::to_string(timeout)); + send(cmd, reply_callback); + return *this; + } + + client& + client::bzpopmax(const std::vector& keys, int timeout, const reply_callback_t& reply_callback) { + std::vector cmd = {"BZPOPMAX"}; + cmd.insert(cmd.end(), keys.begin(), keys.end()); + cmd.push_back(std::to_string(timeout)); + send(cmd, reply_callback); + return *this; + } + + client& + client::client_id(const reply_callback_t& reply_callback) { + send({"CLIENT", "ID"}, reply_callback); + return *this; + } + client & client::client_list(const reply_callback_t &reply_callback) { send({"CLIENT", "LIST"}, reply_callback); @@ -653,6 +677,21 @@ namespace cpp_redis { return *this; } + client& + client::client_unblock(int id, const reply_callback_t& reply_callback) { + send({"CLIENT", "UNBLOCK", std::to_string(id)}, reply_callback); + return *this; + } + + client& + client::client_unblock(int id, bool witherror, const reply_callback_t& reply_callback) { + if (witherror) + send({"CLIENT", "UNBLOCK", std::to_string(id), "ERROR"}, reply_callback); + else + send({"CLIENT", "UNBLOCK", std::to_string(id)}, reply_callback); + return *this; + } + client & client::cluster_addslots(const std::vector &p_slots, const reply_callback_t &reply_callback) { std::vector cmd = {"CLUSTER", "ADDSLOTS"}; @@ -2529,6 +2568,18 @@ namespace cpp_redis { return *this; } + client& + client::zpopmin(const std::string& key, int count, const reply_callback_t& reply_callback) { + send({"ZPOPMIN", key, std::to_string(count)}, reply_callback); + return *this; + } + + client& + client::zpopmax(const std::string& key, int count, const reply_callback_t& reply_callback) { + send({"ZPOPMAX", key, std::to_string(count)}, reply_callback); + return *this; + } + client & client::zrange(const std::string &key, int start, int stop, const reply_callback_t &reply_callback) { send({"ZRANGE", key, std::to_string(start), std::to_string(stop)}, reply_callback); @@ -3239,6 +3290,21 @@ namespace cpp_redis { return exec_cmd([=](const reply_callback_t &cb) -> client & { return brpoplpush(src, dst, timeout, cb); }); } + std::future + client::bzpopmin(const std::vector& keys, int timeout) { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return bzpopmin(keys, timeout, cb); }); + } + + std::future + client::bzpopmax(const std::vector& keys, int timeout) { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return bzpopmax(keys, timeout, cb); }); + } + + std::future + client::client_id() { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return client_id(cb); }); + } + std::future client::client_list() { return exec_cmd([=](const reply_callback_t &cb) -> client & { return client_list(cb); }); @@ -3264,6 +3330,11 @@ namespace cpp_redis { return exec_cmd([=](const reply_callback_t &cb) -> client & { return client_setname(name, cb); }); } + std::future + client::client_unblock(int id, bool witherror) { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return client_unblock(id, witherror, cb); }); + } + std::future client::cluster_addslots(const std::vector &p_slots) { return exec_cmd([=](const reply_callback_t &cb) -> client & { return cluster_addslots(p_slots, cb); }); @@ -4406,6 +4477,15 @@ namespace cpp_redis { return exec_cmd([=](const reply_callback_t &cb) -> client & { return zlexcount(key, min, max, cb); }); } + std::future + client::zpopmin(const std::string& key, int count) { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return zpopmin(key, count, cb); }); + } + std::future + client::zpopmax(const std::string& key, int count) { + return exec_cmd([=](const reply_callback_t& cb) -> client& { return zpopmax(key, count, cb); }); + } + std::future client::zrange(const std::string &key, int start, int stop, bool withscores) { return exec_cmd([=](const reply_callback_t &cb) -> client & { return zrange(key, start, stop, withscores, cb); });