sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.64k stars 351 forks source link

Use unsigned type for cursors #570

Closed tyler92 closed 5 months ago

tyler92 commented 5 months ago

We faced the issue when the SCAN command returned too big value for long long type which led to the error Invalid cursor reply: 9286422431637963776. This happened with AWS ElastiCache (Redis). According to the documentation:

SCAN, SSCAN, HSCAN and ZSCAN return a two element multi-bulk reply, where the first element is a string representing an unsigned 64 bit number (the cursor), and the second element is a multi-bulk with an array of elements.

Also, the same issue was fixed for Spring: https://github.com/spring-projects/spring-data-redis/issues/2796

I realize this change is quite big and probably a braking change, but I believe we need to fix it. So I replaced all long long cursors with Cursor alias which is unsigned long long. Probably it's better to use std::uint64_t to be more precise.

sewenew commented 5 months ago

Thanks for reporting this problem! I'll take a review on it ASAP.

Sorry for the late reply, too busy these days.

Regards

sewenew commented 5 months ago

Thanks again for your contribution!

I moved the Cursor definition to sw/redis++/utils. So that C++ 11 build can also use it.

Regards