How to use the ring.func.base.execute_bulk_item function in ring

To help you get started, we’ve selected a few ring 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 youknowone / ring / ring / func / asyncio.py View on Github external
def get_or_update_many(self, wire, *args_list):
        keys = self.key_many(wire, *args_list)
        miss_value = object()
        results = yield from wire.storage.get_many(
            keys, miss_value=miss_value)

        miss_indices = []
        for i, akr in enumerate(zip(args_list, keys, results)):
            args, key, result = akr
            if result is not miss_value:
                continue
            miss_indices.append(i)

        new_results = yield from asyncio.gather(*(
            fbase.execute_bulk_item(wire, args_list[i]) for i in miss_indices))
        new_keys = [keys[i] for i in miss_indices]
        yield from wire.storage.set_many(new_keys, new_results)

        for new_i, old_i in enumerate(miss_indices):
            results[old_i] = new_results[new_i]
        return results
github youknowone / ring / ring / func / asyncio.py View on Github external
def execute_many(self, wire, *args_list):
        return asyncio.gather(*(
            fbase.execute_bulk_item(wire, args) for args in args_list))
github youknowone / ring / ring / func / sync.py View on Github external
def execute_many(self, wire, *args_list):
        values = [fbase.execute_bulk_item(wire, args) for args in args_list]
        return values
github youknowone / ring / ring / func / sync.py View on Github external
def get_or_update_many(self, wire, *args_list):
        keys = self.key_many(wire, *args_list)
        miss_value = object()
        results = wire.storage.get_many(keys, miss_value=miss_value)

        miss_indices = []
        for i, akr in enumerate(zip(args_list, keys, results)):
            args, key, result = akr
            if result is not miss_value:
                continue
            miss_indices.append(i)

        new_results = [
            fbase.execute_bulk_item(wire, args_list[i]) for i in miss_indices]
        new_keys = [keys[i] for i in miss_indices]
        wire.storage.set_many(new_keys, new_results)

        for new_i, old_i in enumerate(miss_indices):
            results[old_i] = new_results[new_i]
        return results