Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def hscan(self, key, cursor=0, match=None, count=None):
"""Incrementally iterate hash fields and associated values."""
args = [key, cursor]
match is not None and args.extend([b'MATCH', match])
count is not None and args.extend([b'COUNT', count])
fut = self.execute(b'HSCAN', *args)
return wait_convert(fut, _make_pairs)
def unlink(self, key, *keys):
"""Delete a key asynchronously in another thread."""
return wait_convert(self.execute(b'UNLINK', key, *keys), int)
>>> match = 'something*'
>>> cur = b'0'
>>> while cur:
... cur, keys = await redis.scan(cur, match=match)
... for key in keys:
... print('Matched:', key)
"""
args = []
if match is not None:
args += [b'MATCH', match]
if count is not None:
args += [b'COUNT', count]
fut = self.execute(b'SCAN', cursor, *args)
return wait_convert(fut, lambda o: (int(o[0]), o[1]))
def geopos(self, key, member, *members, **kwargs):
"""Returns longitude and latitude of members of a geospatial index.
:rtype: list[GeoPoint or None]
"""
fut = self.execute(b'GEOPOS', key, member, *members, **kwargs)
return wait_convert(fut, make_geopos)
def geodist(self, key, member1, member2, unit='m'):
"""Returns the distance between two members of a geospatial index.
:rtype: list[float or None]
"""
fut = self.execute(b'GEODIST', key, member1, member2, unit)
return wait_convert(fut, make_geodist)
def time(self):
"""Return current server time."""
fut = self.execute(b'TIME')
return wait_convert(fut, to_time)
def master_address(self, name):
"""Returns a (host, port) pair for the given ``name``."""
fut = self.execute(b'get-master-addr-by-name', name, encoding='utf-8')
return wait_convert(fut, parse_address)
def xinfo_consumers(self, stream, group_name):
"""Retrieve consumers of a consumer group"""
fut = self.execute(b'XINFO', b'CONSUMERS', stream, group_name)
return wait_convert(fut, parse_lists_to_dicts)