refs: change do_for_each_*() functions to take ref_cache arguments