diff --git a/README.md b/README.md index 158a8e66..b95b32ab 100644 --- a/README.md +++ b/README.md @@ -1336,7 +1336,7 @@ redis.smembers("s1", std::back_inserter(s_vec)); ##### SCAN Commands ```C++ -auto cursor = 0LL; +sw::redis::Cursor cursor = 0; auto pattern = "*pattern*"; auto count = 5; std::unordered_set keys; diff --git a/src/sw/redis++/command.h b/src/sw/redis++/command.h index 3a170cf8..c10a536d 100644 --- a/src/sw/redis++/command.h +++ b/src/sw/redis++/command.h @@ -233,10 +233,10 @@ void restore(Connection &connection, bool replace); inline void scan(Connection &connection, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { - connection.send("SCAN %lld MATCH %b COUNT %lld", + connection.send("SCAN %llu MATCH %b COUNT %lld", cursor, pattern.data(), pattern.size(), count); @@ -729,10 +729,10 @@ inline void hmset(Connection &connection, inline void hscan(Connection &connection, const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { - connection.send("HSCAN %b %lld MATCH %b COUNT %lld", + connection.send("HSCAN %b %llu MATCH %b COUNT %lld", key.data(), key.size(), cursor, pattern.data(), pattern.size(), @@ -937,10 +937,10 @@ inline void srem_range(Connection &connection, inline void sscan(Connection &connection, const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { - connection.send("SSCAN %b %lld MATCH %b COUNT %lld", + connection.send("SSCAN %b %llu MATCH %b COUNT %lld", key.data(), key.size(), cursor, pattern.data(), pattern.size(), @@ -1294,10 +1294,10 @@ inline void zrevrank(Connection &connection, inline void zscan(Connection &connection, const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { - connection.send("ZSCAN %b %lld MATCH %b COUNT %lld", + connection.send("ZSCAN %b %llu MATCH %b COUNT %lld", key.data(), key.size(), cursor, pattern.data(), pattern.size(), diff --git a/src/sw/redis++/cxx17/sw/redis++/cxx_utils.h b/src/sw/redis++/cxx17/sw/redis++/cxx_utils.h index 92bbd5a8..92ada30c 100644 --- a/src/sw/redis++/cxx17/sw/redis++/cxx_utils.h +++ b/src/sw/redis++/cxx17/sw/redis++/cxx_utils.h @@ -43,6 +43,8 @@ using Monostate = std::monostate; template using IsInvocable = std::is_invocable; +using Cursor = unsigned long long; + } } diff --git a/src/sw/redis++/queued_redis.h b/src/sw/redis++/queued_redis.h index 5285b749..32d26b14 100644 --- a/src/sw/redis++/queued_redis.h +++ b/src/sw/redis++/queued_redis.h @@ -260,22 +260,22 @@ class QueuedRedis { // TODO: sort - QueuedRedis& scan(long long cursor, + QueuedRedis& scan(Cursor cursor, const StringView &pattern, long long count) { return command(cmd::scan, cursor, pattern, count); } - QueuedRedis& scan(long long cursor) { + QueuedRedis& scan(Cursor cursor) { return scan(cursor, "*", 10); } - QueuedRedis& scan(long long cursor, + QueuedRedis& scan(Cursor cursor, const StringView &pattern) { return scan(cursor, pattern, 10); } - QueuedRedis& scan(long long cursor, + QueuedRedis& scan(Cursor cursor, long long count) { return scan(cursor, "*", count); } @@ -740,26 +740,26 @@ class QueuedRedis { } QueuedRedis& hscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { return command(cmd::hscan, key, cursor, pattern, count); } QueuedRedis& hscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern) { return hscan(key, cursor, pattern, 10); } QueuedRedis& hscan(const StringView &key, - long long cursor, + Cursor cursor, long long count) { return hscan(key, cursor, "*", count); } QueuedRedis& hscan(const StringView &key, - long long cursor) { + Cursor cursor) { return hscan(key, cursor, "*", 10); } @@ -930,26 +930,26 @@ class QueuedRedis { } QueuedRedis& sscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { return command(cmd::sscan, key, cursor, pattern, count); } QueuedRedis& sscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern) { return sscan(key, cursor, pattern, 10); } QueuedRedis& sscan(const StringView &key, - long long cursor, + Cursor cursor, long long count) { return sscan(key, cursor, "*", count); } QueuedRedis& sscan(const StringView &key, - long long cursor) { + Cursor cursor) { return sscan(key, cursor, "*", 10); } @@ -1250,26 +1250,26 @@ class QueuedRedis { } QueuedRedis& zscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern, long long count) { return command(cmd::zscan, key, cursor, pattern, count); } QueuedRedis& zscan(const StringView &key, - long long cursor, + Cursor cursor, const StringView &pattern) { return zscan(key, cursor, pattern, 10); } QueuedRedis& zscan(const StringView &key, - long long cursor, + Cursor cursor, long long count) { return zscan(key, cursor, "*", count); } QueuedRedis& zscan(const StringView &key, - long long cursor) { + Cursor cursor) { return zscan(key, cursor, "*", 10); } diff --git a/src/sw/redis++/redis.h b/src/sw/redis++/redis.h index 69b1cf24..6e0676f2 100644 --- a/src/sw/redis++/redis.h +++ b/src/sw/redis++/redis.h @@ -480,7 +480,7 @@ class Redis { /// /// Example: /// @code{.cpp} - /// auto cursor = 0LL; + /// sw::redis::Cursor cursor = 0; /// std::unordered_set keys; /// while (true) { /// cursor = redis.scan(cursor, "pattern:*", 10, std::inserter(keys, keys.begin())); @@ -497,10 +497,10 @@ class Redis { /// @see https://redis.io/commands/scan /// TODO: support the TYPE option for Redis 6.0. template - long long scan(long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor scan(Cursor cursor, + const StringView &pattern, + long long count, + Output output); /// @brief Scan all keys of the database. /// @param cursor Cursor. @@ -508,8 +508,8 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/scan template - long long scan(long long cursor, - Output output); + Cursor scan(Cursor cursor, + Output output); /// @brief Scan keys of the database matching the given pattern. /// @param cursor Cursor. @@ -518,9 +518,9 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/scan template - long long scan(long long cursor, - const StringView &pattern, - Output output); + Cursor scan(Cursor cursor, + const StringView &pattern, + Output output); /// @brief Scan keys of the database matching the given pattern. /// @param cursor Cursor. @@ -529,9 +529,9 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/scan template - long long scan(long long cursor, - long long count, - Output output); + Cursor scan(Cursor cursor, + long long count, + Output output); /// @brief Update the last access time of the given key. /// @param key Key. @@ -1490,7 +1490,7 @@ class Redis { /// /// Example: /// @code{.cpp} - /// auto cursor = 0LL; + /// sw::redis::Cursor cursor = 0; /// std::unordered_map kvs; /// while (true) { /// cursor = redis.hscan("hash", cursor, "pattern:*", 10, std::inserter(kvs, kvs.begin())); @@ -1507,11 +1507,11 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/hscan template - long long hscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); /// @brief Scan fields of the given hash matching the given pattern. /// @param key Key where the hash is stored. @@ -1521,10 +1521,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/hscan template - long long hscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); /// @brief Scan all fields of the given hash. /// @param key Key where the hash is stored. @@ -1534,10 +1534,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/hscan template - long long hscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + long long count, + Output output); /// @brief Scan all fields of the given hash. /// @param key Key where the hash is stored. @@ -1546,9 +1546,9 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/hscan template - long long hscan(const StringView &key, - long long cursor, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + Output output); /// @brief Set hash field to value. /// @param key Key where the hash is stored. @@ -1875,7 +1875,7 @@ class Redis { /// /// Example: /// @code{.cpp} - /// auto cursor = 0LL; + /// sw::redis::Cursor cursor = 0; /// std::unordered_set members; /// while (true) { /// cursor = redis.sscan("set", cursor, "pattern:*", @@ -1893,11 +1893,11 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/sscan template - long long sscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); /// @brief Scan members of the set matching the given pattern. /// @param key Key where the set is stored. @@ -1907,10 +1907,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/sscan template - long long sscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); /// @brief Scan all members of the given set. /// @param key Key where the set is stored. @@ -1920,10 +1920,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/sscan template - long long sscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + long long count, + Output output); /// @brief Scan all members of the given set. /// @param key Key where the set is stored. @@ -1932,9 +1932,9 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/sscan template - long long sscan(const StringView &key, - long long cursor, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + Output output); /// @brief Get the union between the first set and all successive sets. /// @param first Iterator to the first set. @@ -2811,7 +2811,7 @@ class Redis { /// /// Example: /// @code{.cpp} - /// auto cursor = 0LL; + /// sw::redis::Cursor cursor = 0; /// std::vector> members; /// while (true) { /// cursor = redis.zscan("zset", cursor, "pattern:*", @@ -2829,11 +2829,11 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/zscan template - long long zscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); /// @brief Scan members of the given sorted set matching the given pattern. /// @param key Key where the sorted set is stored. @@ -2843,10 +2843,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/zscan template - long long zscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); /// @brief Scan all members of the given sorted set. /// @param key Key where the sorted set is stored. @@ -2856,10 +2856,10 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/zscan template - long long zscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + long long count, + Output output); /// @brief Scan all members of the given sorted set. /// @param key Key where the sorted set is stored. @@ -2868,9 +2868,9 @@ class Redis { /// @return The cursor to be used for the next scan operation. /// @see https://redis.io/commands/zscan template - long long zscan(const StringView &key, - long long cursor, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + Output output); /// @brief Get the score of the given member. /// @param key Key where the sorted set is stored. diff --git a/src/sw/redis++/redis.hpp b/src/sw/redis++/redis.hpp index e1550d48..3c97224c 100644 --- a/src/sw/redis++/redis.hpp +++ b/src/sw/redis++/redis.hpp @@ -173,32 +173,32 @@ inline void Redis::restore(const StringView &key, } template -long long Redis::scan(long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor Redis::scan(Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::scan, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long Redis::scan(long long cursor, - const StringView &pattern, - Output output) { +inline Cursor Redis::scan(Cursor cursor, + const StringView &pattern, + Output output) { return scan(cursor, pattern, 10, output); } template -inline long long Redis::scan(long long cursor, - long long count, - Output output) { +inline Cursor Redis::scan(Cursor cursor, + long long count, + Output output) { return scan(cursor, "*", count, output); } template -inline long long Redis::scan(long long cursor, - Output output) { +inline Cursor Redis::scan(Cursor cursor, + Output output) { return scan(cursor, "*", 10, output); } @@ -383,36 +383,36 @@ inline void Redis::hmset(const StringView &key, Input first, Input last) { } template -long long Redis::hscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor Redis::hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::hscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long Redis::hscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor Redis::hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return hscan(key, cursor, pattern, 10, output); } template -inline long long Redis::hscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor Redis::hscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return hscan(key, cursor, "*", count, output); } template -inline long long Redis::hscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor Redis::hscan(const StringView &key, + Cursor cursor, + Output output) { return hscan(key, cursor, "*", 10, output); } @@ -516,36 +516,36 @@ long long Redis::srem(const StringView &key, Input first, Input last) { } template -long long Redis::sscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor Redis::sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::sscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long Redis::sscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor Redis::sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return sscan(key, cursor, pattern, 10, output); } template -inline long long Redis::sscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor Redis::sscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return sscan(key, cursor, "*", count, output); } template -inline long long Redis::sscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor Redis::sscan(const StringView &key, + Cursor cursor, + Output output) { return sscan(key, cursor, "*", 10, output); } @@ -773,36 +773,36 @@ void Redis::zrevrangebyscore(const StringView &key, } template -long long Redis::zscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor Redis::zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::zscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long Redis::zscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor Redis::zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return zscan(key, cursor, pattern, 10, output); } template -inline long long Redis::zscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor Redis::zscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return zscan(key, cursor, "*", count, output); } template -inline long long Redis::zscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor Redis::zscan(const StringView &key, + Cursor cursor, + Output output) { return zscan(key, cursor, "*", 10, output); } diff --git a/src/sw/redis++/redis_cluster.h b/src/sw/redis++/redis_cluster.h index 23cb1710..011c030e 100644 --- a/src/sw/redis++/redis_cluster.h +++ b/src/sw/redis++/redis_cluster.h @@ -447,28 +447,28 @@ class RedisCluster { } template - long long hscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); template - long long hscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); template - long long hscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + long long count, + Output output); template - long long hscan(const StringView &key, - long long cursor, - Output output); + Cursor hscan(const StringView &key, + Cursor cursor, + Output output); long long hset(const StringView &key, const StringView &field, const StringView &val); @@ -578,28 +578,28 @@ class RedisCluster { } template - long long sscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); template - long long sscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); template - long long sscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + long long count, + Output output); template - long long sscan(const StringView &key, - long long cursor, - Output output); + Cursor sscan(const StringView &key, + Cursor cursor, + Output output); template void sunion(Input first, Input last, Output output); @@ -825,28 +825,28 @@ class RedisCluster { OptionalLongLong zrevrank(const StringView &key, const StringView &member); template - long long zscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output); template - long long zscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output); template - long long zscan(const StringView &key, - long long cursor, - long long count, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + long long count, + Output output); template - long long zscan(const StringView &key, - long long cursor, - Output output); + Cursor zscan(const StringView &key, + Cursor cursor, + Output output); OptionalDouble zscore(const StringView &key, const StringView &member); diff --git a/src/sw/redis++/redis_cluster.hpp b/src/sw/redis++/redis_cluster.hpp index 80079b55..ab109703 100644 --- a/src/sw/redis++/redis_cluster.hpp +++ b/src/sw/redis++/redis_cluster.hpp @@ -354,36 +354,36 @@ inline void RedisCluster::hmset(const StringView &key, Input first, Input last) } template -long long RedisCluster::hscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor RedisCluster::hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::hscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long RedisCluster::hscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor RedisCluster::hscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return hscan(key, cursor, pattern, 10, output); } template -inline long long RedisCluster::hscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor RedisCluster::hscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return hscan(key, cursor, "*", count, output); } template -inline long long RedisCluster::hscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor RedisCluster::hscan(const StringView &key, + Cursor cursor, + Output output) { return hscan(key, cursor, "*", 10, output); } @@ -487,36 +487,36 @@ long long RedisCluster::srem(const StringView &key, Input first, Input last) { } template -long long RedisCluster::sscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor RedisCluster::sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::sscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long RedisCluster::sscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor RedisCluster::sscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return sscan(key, cursor, pattern, 10, output); } template -inline long long RedisCluster::sscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor RedisCluster::sscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return sscan(key, cursor, "*", count, output); } template -inline long long RedisCluster::sscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor RedisCluster::sscan(const StringView &key, + Cursor cursor, + Output output) { return sscan(key, cursor, "*", 10, output); } @@ -744,36 +744,36 @@ void RedisCluster::zrevrangebyscore(const StringView &key, } template -long long RedisCluster::zscan(const StringView &key, - long long cursor, - const StringView &pattern, - long long count, - Output output) { +Cursor RedisCluster::zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + long long count, + Output output) { auto reply = command(cmd::zscan, key, cursor, pattern, count); return reply::parse_scan_reply(*reply, output); } template -inline long long RedisCluster::zscan(const StringView &key, - long long cursor, - const StringView &pattern, - Output output) { +inline Cursor RedisCluster::zscan(const StringView &key, + Cursor cursor, + const StringView &pattern, + Output output) { return zscan(key, cursor, pattern, 10, output); } template -inline long long RedisCluster::zscan(const StringView &key, - long long cursor, - long long count, - Output output) { +inline Cursor RedisCluster::zscan(const StringView &key, + Cursor cursor, + long long count, + Output output) { return zscan(key, cursor, "*", count, output); } template -inline long long RedisCluster::zscan(const StringView &key, - long long cursor, - Output output) { +inline Cursor RedisCluster::zscan(const StringView &key, + Cursor cursor, + Output output) { return zscan(key, cursor, "*", 10, output); } diff --git a/src/sw/redis++/reply.h b/src/sw/redis++/reply.h index e78fe164..c5ba050c 100644 --- a/src/sw/redis++/reply.h +++ b/src/sw/redis++/reply.h @@ -115,7 +115,7 @@ template ::value, T parse(ParseTag, redisReply &reply); template -long long parse_scan_reply(redisReply &reply, Output output); +Cursor parse_scan_reply(redisReply &reply, Output output); inline bool is_error(redisReply &reply) { return reply.type == REDIS_REPLY_ERROR; @@ -455,7 +455,7 @@ T parse(ParseTag, redisReply &reply) { } template -long long parse_scan_reply(redisReply &reply, Output output) { +Cursor parse_scan_reply(redisReply &reply, Output output) { if (reply.elements != 2 || reply.element == nullptr) { throw ProtoError("Invalid scan reply"); } @@ -467,9 +467,9 @@ long long parse_scan_reply(redisReply &reply, Output output) { } auto cursor_str = reply::parse(*cursor_reply); - long long new_cursor = 0; + Cursor new_cursor = 0; try { - new_cursor = std::stoll(cursor_str); + new_cursor = std::stoull(cursor_str); } catch (const std::exception &e) { throw ProtoError("Invalid cursor reply: " + cursor_str); } diff --git a/test/src/sw/redis++/hash_cmds_test.hpp b/test/src/sw/redis++/hash_cmds_test.hpp index 1f41a0e3..4c948917 100644 --- a/test/src/sw/redis++/hash_cmds_test.hpp +++ b/test/src/sw/redis++/hash_cmds_test.hpp @@ -149,7 +149,7 @@ void HashCmdTest::_test_hscan() { _redis.hmset(key, items.begin(), items.end()); std::unordered_map item_map; - auto cursor = 0; + Cursor cursor = 0; while (true) { cursor = _redis.hscan(key, cursor, "f*", 2, std::inserter(item_map, item_map.end())); if (cursor == 0) { diff --git a/test/src/sw/redis++/keys_cmds_test.hpp b/test/src/sw/redis++/keys_cmds_test.hpp index de21f8d1..e50da32e 100644 --- a/test/src/sw/redis++/keys_cmds_test.hpp +++ b/test/src/sw/redis++/keys_cmds_test.hpp @@ -145,7 +145,7 @@ void KeysCmdTest::_test_scan(Redis &instance) { instance.set(k2, "v"); instance.set(k3, "v"); - auto cursor = 0; + Cursor cursor = 0; std::unordered_set res; while (true) { cursor = instance.scan(cursor, "*" + key_pattern + "*", 2, std::inserter(res, res.end())); diff --git a/test/src/sw/redis++/set_cmds_test.hpp b/test/src/sw/redis++/set_cmds_test.hpp index 1a4c24bf..40fc8484 100644 --- a/test/src/sw/redis++/set_cmds_test.hpp +++ b/test/src/sw/redis++/set_cmds_test.hpp @@ -153,7 +153,7 @@ void SetCmdTest::_test_sscan() { _redis.sadd(key, members.begin(), members.end()); std::unordered_set res; - long long cursor = 0; + Cursor cursor = 0; while (true) { cursor = _redis.sscan(key, cursor, "m*", 1, std::inserter(res, res.end())); if (cursor == 0) { diff --git a/test/src/sw/redis++/zset_cmds_test.hpp b/test/src/sw/redis++/zset_cmds_test.hpp index 9f6c05a0..360c43ed 100644 --- a/test/src/sw/redis++/zset_cmds_test.hpp +++ b/test/src/sw/redis++/zset_cmds_test.hpp @@ -103,7 +103,7 @@ void ZSetCmdTest::_test_zscan() { _redis.zadd(key, s.begin(), s.end()); std::map res; - auto cursor = 0; + Cursor cursor = 0; while (true) { cursor = _redis.zscan(key, cursor, "m*", 2, std::inserter(res, res.end())); if (cursor == 0) {