def cache_resources(self, resource_type, specific_ids=None): """ Save all resources of a given type to memory, for in-memory lookup ops This is a PREFETCH operation, and EnhancedResourceRegistryClient objects that use the cache functionality should NOT be kept across service calls. """ #log.info("Caching resources: %s", resource_type) #log.debug("This cache is %s", self) time_caching_start = get_ion_ts() resource_objs = [] if specific_ids is None: resource_objs, _ = self.RR.find_resources(restype=resource_type, id_only=False) else: assert type(specific_ids) is list if specific_ids: resource_objs = self.RR.read_mult(specific_ids) lookups = DotDict() lookups.by_id = {} lookups.by_name = {} self._cached_resources[resource_type] = lookups for r in resource_objs: self._add_resource_to_cache(resource_type, r) time_caching_stop = get_ion_ts() total_time = int(time_caching_stop) - int(time_caching_start)