def METHOD_NAME(document_ids, lang, document_type):
    """ Get a cache key for all given document ids.
    """
    if not document_ids:
        return []
    versions = DBSession.query(CacheVersion). \
        filter(CacheVersion.document_id.in_(document_ids)). \
        join(Document,
             Document.document_id == CacheVersion.document_id). \
        filter(Document.redirects_to.is_(None)). \
        all()
    version_for_documents = {v.document_id: v.version for v in versions}
    return [
        _format_cache_key(
            document_id,
            lang,
            version_for_documents.get(document_id),
            document_type
        ) for document_id in document_ids
        if version_for_documents.get(document_id)
    ]