Have you ever wondered what the cursor value that Redis returns for SCAN commands means? I did, and set out to make sense of these seemingly arbitrary numbers.
Some time ago I was reading a StackOverflow article, that linked the documentation inside the Redis SCAN implementation. At the time, I only quickly skimmed the text. I remember thinking that it should be possible to come up with an estimate of how far along the SCAN is.
Today I 'cracked' the algorithm. It is not really that much of an achievement, given it is thoroughly documented, but figuring it out without the source code documentation still gave me a Eureka-moment. The result: