Generic
SCAN
Scan the database for keys.
Arguments
cursorbodyintrequired
The cursor, use 0 in the beginning and then use the returned cursor for subsequent calls.
matchbodystrrequired
Glob-style pattern to filter by field names.
countbodyintrequired
Number of fields to return per call.
typebodystr
Filter by type.
For example string, hash, set, zset, list, stream.
Response
Tuple[int, List[str]]required
The new cursor and the keys as a tuple.
If the new cursor is 0 the iteration is complete.
Use the new cursor for subsequent calls.
Example
# Get all keyscursor = 0results = []while True: cursor, keys = redis.scan(cursor, match="*") results.extend(keys) if cursor == 0: break