def _cache_descriptor(descriptor, descritor_cache):
    """De-reference and cache a RunStop document

    The de-referenced Document is cached against the
    ObjectId and the uid -> ObjectID mapping is stored.

    Parameters
    ----------
    descriptor : dict
        raw pymongo dictionary. This is expected to have
        an entry `_id` with the ObjectId used by mongo.

    Returns
    -------
    descriptor : dict
        Document instance for this EventDescriptor document.
        The ObjectId has been stripped.
    """
    descriptor = dict(descriptor)
    oid = descriptor.pop('_id', None)
    try:
        descriptor['run_start']
    except KeyError:
        descriptor['run_start'] = descriptor.pop('run_start_id')
    descritor_cache[descriptor['uid']] = descriptor
    if oid is not None:
        descritor_cache[oid] = descriptor
    return descriptor
