Make discovery_cache more generic