SCANIterate the keyspace incrementally: each call walks ~COUNT buckets of one shard and returns the next cursor.
| Syntax | SCAN cursor [MATCH pattern] [COUNT count] [TYPE type] |
| Group | scan |
| Arity | -2 |
| Since | 4.0.0 |
| Flags | readonly |
| Complexity | O(COUNT) buckets per call, amortised O(N) for a full sweep — reverse-binary cursor, rehash-tolerant (a key present for the whole sweep is returned at least once even across table growth) |
| Redis compatibility | differs: cursors encode (shard, position), so a cursor is only valid on the server and shard count that issued it — the same per-node property Redis Cluster cursors have. MATCH and TYPE filter after collection; COUNT bounds the buckets visited, not the keys returned |