'Retrieve an XCom value, optionally meeting certain criteria'

@classmethod
@provide_session
def get_many(cls, execution_date, key=None, task_ids=None, dag_ids=None, include_prior_dates=False, limit=100, session=None):

    filters = []
    if key:
        filters.append((cls.key == key))
    if task_ids:
        filters.append(cls.task_id.in_(as_tuple(task_ids)))
    if dag_ids:
        filters.append(cls.dag_id.in_(as_tuple(dag_ids)))
    if include_prior_dates:
        filters.append((cls.execution_date <= execution_date))
    else:
        filters.append((cls.execution_date == execution_date))
    query = session.query(cls).filter(and_(*filters)).order_by(cls.execution_date.desc(), cls.timestamp.desc()).limit(limit)
    return query.all()
