MCPcopy
hub / github.com/redis/redis-py / scan_iter

Method scan_iter

redis/commands/core.py:5971–5997  ·  view source on GitHub ↗

Make an iterator using the SCAN command so that the client doesn't need to remember the cursor position. ``match`` allows for filtering the keys by pattern ``count`` provides a hint to Redis about the number of keys to return per batch. ``_type

(
        self,
        match: Union[PatternT, None] = None,
        count: Optional[int] = None,
        _type: Optional[str] = None,
        **kwargs,
    )

Source from the content-addressed store, hash-verified

5969 return self.execute_command("SCAN", *pieces, **kwargs)
5970
5971 def scan_iter(
5972 self,
5973 match: Union[PatternT, None] = None,
5974 count: Optional[int] = None,
5975 _type: Optional[str] = None,
5976 **kwargs,
5977 ) -> Iterator:
5978 """
5979 Make an iterator using the SCAN command so that the client doesn't
5980 need to remember the cursor position.
5981
5982 ``match`` allows for filtering the keys by pattern
5983
5984 ``count`` provides a hint to Redis about the number of keys to
5985 return per batch.
5986
5987 ``_type`` filters the returned values by a particular Redis type.
5988 Stock Redis instances allow for the following types:
5989 HASH, LIST, SET, STREAM, STRING, ZSET
5990 Additionally, Redis modules can expose other types as well.
5991 """
5992 cursor = "0"
5993 while cursor != 0:
5994 cursor, data = self.scan(
5995 cursor=cursor, match=match, count=count, _type=_type, **kwargs
5996 )
5997 yield from data
5998
5999 @overload
6000 def sscan(

Callers 4

test_scan_iterMethod · 0.45
test_scan_iterMethod · 0.45

Calls 1

scanMethod · 0.95

Tested by 4

test_scan_iterMethod · 0.36
test_scan_iterMethod · 0.36