def _get_interval_embedding_from_cache(nf, RIF, cache):
    """
    Evaluate RIF(nf.gen_embedding()) where RIF is a RealIntervalField with
    some precision. This is a real interval that is guarenteed to contain the
    prefered root of the defining polynomial of the number field.

    To avoid re-evaluation, use cache which is (a reference) to a python
    dictionary.

    The idea is that while working over one number field, all instances of
    (_Factorized)SqrtLinCombination have a reference to the same (shared) python
    dictionary and fill it in as needed.

    Unfortunately, the reference to the cache needs to passed down along a lot
    of places. There might be a nicer mechanism for doing this.
    """
    if not cache is None and 'gen_embedding' in cache:
        gen_embedding = cache['gen_embedding']
    else:
        gen_embedding = nf.gen_embedding()
        if not cache is None:
            cache['gen_embedding'] = gen_embedding
    prec = RIF.prec()
    if not cache is None and prec in cache:
        return cache[prec]
    interval = RIF(gen_embedding)
    if not cache is None:
        cache[prec] = interval
    return interval
