Retrieve an object from Redis using a pipeline.

    Arguments:
        template: a dictionary containg the keys for the object and
            template strings for the corresponding redis keys. The template
            string uses named string interpolation format. Example:

            {
                'username': 'user:$(id)s:username',
                'email': 'user:$(id)s:email',
                'phone': 'user:$(id)s:phone'
            }

        indexes: a dictionary containing the values to use to cosntruct the
            redis keys: Example:

            {
                'id': 342
            }

    Returns: a dictionary with the same keys as template, but containing
        the values retrieved from redis, if all the values are retrieved.
        If any value is missing, returns None. Example:

        {
            'username': 'bob',
            'email': 'bob@example.com',
            'phone': '555-555-5555'
        }

def retrieve_object(cache, template, indexes):
    """Retrieve an object from Redis using a pipeline.

    Arguments:
        template: a dictionary containg the keys for the object and
            template strings for the corresponding redis keys. The template
            string uses named string interpolation format. Example:

            {
                'username': 'user:$(id)s:username',
                'email': 'user:$(id)s:email',
                'phone': 'user:$(id)s:phone'
            }

        indexes: a dictionary containing the values to use to cosntruct the
            redis keys: Example:

            {
                'id': 342
            }

    Returns: a dictionary with the same keys as template, but containing
        the values retrieved from redis, if all the values are retrieved.
        If any value is missing, returns None. Example:

        {
            'username': 'bob',
            'email': 'bob@example.com',
            'phone': '555-555-5555'
        }

    """
    keys = []
    with cache as redis_connection:
        pipe = redis_connection.pipeline()
        for (result_key, redis_key_template) in template.items():
            keys.append(result_key)
            pipe.get(redis_key_template % indexes)
        results = pipe.execute()
    return None if None in results else dict(zip(keys, results))