Sorted Set
ZSCAN
Scan a sorted set
Return a paginated list of members and their scores of an ordered set matching a pattern.
Arguments
keybodystrrequired
The key of the sorted set.
cursorbodyintrequired
The cursor, use 0 in the beginning and then use the returned cursor for subsequent calls.
matchbodystr
Glob-style pattern to filter by members.
countbodyint
Number of members to return per call.
Response
Tuple[int, List[str]]required
The new cursor and keys as a tuple.
If the new cursor is 0 the iteration is complete.
Example
# Get all elements of an ordered set.cursor = 0results = []while True: cursor, keys = redis.zscan("myzset", cursor, match="*") results.extend(keys) if cursor == 0: breakfor key, score in results: print(key, score)