common/shared_cache: allow comparator to be adjusted
Allow the use of a comparator that has a value, and for that
comparator to be adjusted at runtime for the purposes for get_next
sort order. Since get_next uses the weak_refs map, that is the
only map that needs to be rebuilt.
We assume, for simplicity, that the comparator can be constructed
with no arguments with some default... otherwise this is messier.