SCAN
Sweep the keyspace and return every match at once; NOT a cursor iterator (COUNT and TYPE are accepted and ignored, and the cursor is always 0).
SCAN cursor [MATCH pattern] [COUNT count]
Complexity
O(N) keys in the WHOLE keyspace, on every call — there is no incremental walk
Complexity and compatibility are read out of kevy's implementation, not copied from Redis's reference. Several genuinely differ.
Redis compatibility
Differs
SCAN is not a cursor iterator. Every call sweeps every shard's entire keyspace and replies with cursor 0 and all matches in one batch, so the standard SCAN loop terminates after one round trip. COUNT and TYPE are accepted and ignored; MATCH is honoured. Redis's incremental, bounded-work, rehash-tolerant guarantees do not exist here