def map(self, key_pattern, func, all_args, timeout=None):
results = []<EOL>keys = [<EOL>make_key(key_pattern, func, args, {})<EOL>for args in all_args<EOL>]<EOL>cached = dict(zip(keys, self.get_many(keys)))<EOL>cache_to_add = {}<EOL>for key, args in zip(keys, all_args):<EOL><INDENT>val = cached[key]<EOL>if val is None:<EOL><INDENT>val = func(*args)<EOL>cache_to_add[key] = val if val is not None else NONE_RESULT<EOL><DEDENT>if val == NONE_RESULT:<EOL><INDENT>val = None<EOL><DEDENT>results.append(val)<EOL><DEDENT>if cache_to_add:<EOL><INDENT>self.set_many(cache_to_add, timeout)<EOL><DEDENT>return results<EOL>
Cache return value of multiple calls.

        Args:
            key_pattern (str): the key pattern to use for generating
                               keys for caches of the decorated function.
            func (function): the function to call.
            all_args (list): a list of args to be used to make calls to
                             the function.
            timeout (int): the cache timeout

        Returns:
            A list of the return values of the calls.

        Example::

            def add(a, b):
                return a + b

            cache.map(key_pat, add, [(1, 2), (3, 4)]) == [3, 7]