How to use the aioredis.util.wait_convert function in aioredis

To help you get started, we’ve selected a few aioredis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aio-libs / aioredis / aioredis / commands / hash.py View on Github external
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)
github aio-libs / aioredis / aioredis / commands / generic.py View on Github external
def unlink(self, key, *keys):
        """Delete a key asynchronously in another thread."""
        return wait_convert(self.execute(b'UNLINK', key, *keys), int)
github aio-libs / aioredis / aioredis / commands / generic.py View on Github external
>>> 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]))
github aio-libs / aioredis / aioredis / commands / geo.py View on Github external
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)
github aio-libs / aioredis / aioredis / commands / geo.py View on Github external
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)
github aio-libs / aioredis / aioredis / commands / server.py View on Github external
def time(self):
        """Return current server time."""
        fut = self.execute(b'TIME')
        return wait_convert(fut, to_time)
github aio-libs / aioredis / aioredis / sentinel / commands.py View on Github external
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)
github aio-libs / aioredis / aioredis / commands / streams.py View on Github external
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)