Concept Flow - SCAN for safe key iteration
Start with cursor = 0
Call SCAN cursor MATCH pattern COUNT n
Receive new cursor and keys batch
Process keys batch
Is cursor == 0?
No→Repeat SCAN with new cursor
Yes
End iteration
SCAN starts with cursor 0, returns a batch of keys and a new cursor. Repeat until cursor returns to 0, safely iterating keys without blocking.