diff --git a/src/sw/redis++/async_redis.h b/src/sw/redis++/async_redis.h index e53f385..c1691c2 100644 --- a/src/sw/redis++/async_redis.h +++ b/src/sw/redis++/async_redis.h @@ -1453,7 +1453,7 @@ class AsyncRedis { template Future zrangebyscore(const StringView &key, const Interval &interval) { - return zrangebyscore(key, interval, {}); + return zrangebyscore(key, interval, {}); } template @@ -1565,6 +1565,32 @@ class AsyncRedis { return zrevrangebylex(key, interval, {}, std::forward(cb)); } + // TODO: withscores parameter + template + Future zrevrangebyscore(const StringView &key, + const Interval &interval, + const LimitOptions &opts) { + return _command(fmt::zrevrangebyscore, + key, interval, opts); + } + + template + auto zrevrangebyscore(const StringView &key, const Interval &interval, const LimitOptions &opts, Callback &&cb) + -> typename std::enable_if::type, Future &&>::value, void>::type { + _callback_fmt_command(std::forward(cb), fmt::zrevrangebyscore, key, interval, opts); + } + + template + Future zrevrangebyscore(const StringView &key, const Interval &interval) { + return zrevrangebyscore(key, interval, {}); + } + + template + auto zrevrangebyscore(const StringView &key, const Interval &interval, Callback &&cb) + -> typename std::enable_if::type, Future &&>::value, void>::type { + return zrevrangebyscore(key, interval, {}, std::forward(cb)); + } + Future zrevrank(const StringView &key, const StringView &member) { return _command(fmt::zrevrank, key, member); } diff --git a/src/sw/redis++/cmd_formatter.h b/src/sw/redis++/cmd_formatter.h index 01b69d7..a683561 100644 --- a/src/sw/redis++/cmd_formatter.h +++ b/src/sw/redis++/cmd_formatter.h @@ -783,6 +783,21 @@ FormattedCommand zrevrangebylex(const StringView &key, opts.count); } +template +FormattedCommand zrevrangebyscore(const StringView &key, + const Interval &interval, + const LimitOptions &opts) { + const auto &min = interval.lower(); + const auto &max = interval.upper(); + + return format_cmd("ZREVRANGEBYSCORE %b %b %b LIMIT %lld %lld", + key.data(), key.size(), + max.data(), max.size(), + min.data(), min.size(), + opts.offset, + opts.count); +} + inline FormattedCommand zrevrank(const StringView &key, const StringView &member) { return format_cmd("ZREVRANK %b %b", key.data(), key.size(), member.data(), member.size()); }