'Get the devices (and keys if any) for remote users from the cache.
Args:
query_list(list): List of (user_id, device_ids), if device_ids is
falsey then return all device ids for that user.
Returns:
(user_ids_not_in_cache, results_map), where user_ids_not_in_cache is
a set of user_ids and results_map is a mapping of
user_id -> device_id -> device_info'

@defer.inlineCallbacks
def get_user_devices_from_cache(self, query_list):

    user_ids = set((user_id for (user_id, _) in query_list))
    user_map = (yield self.get_device_list_last_stream_id_for_remotes(list(user_ids)))
    user_ids_in_cache = set((user_id for (user_id, stream_id) in user_map.items() if stream_id))
    user_ids_not_in_cache = (user_ids - user_ids_in_cache)
    results = {}
    for (user_id, device_id) in query_list:
        if (user_id not in user_ids_in_cache):
            continue
        if device_id:
            device = (yield self._get_cached_user_device(user_id, device_id))
            results.setdefault(user_id, {})[device_id] = device
        else:
            results[user_id] = (yield self._get_cached_devices_for_user(user_id))
    defer.returnValue((user_ids_not_in_cache, results))
