def get_input_id_from_metadata_or_none(self, metadata: InputMetadata) \ -> Optional[str]: input_id_bytes = self.redis.hget(_INPUT_ID_KEY, metadata.redis_field()) if not input_id_bytes: return None input_id = str(input_id_bytes, 'utf-8') # We have the metadata stored, but the file doesn't exist. I can # imagine this happening so let's make this cache mechanism resilient # to that. if not self._input_file_exists(input_id): return None else: return input_id
def _store_input_id(self, metadata: InputMetadata, input_id: str) -> None: field = metadata.redis_field() self.redis.hset(_INPUT_ID_KEY, field, input_id) log.debug(field + ': ' + str(self.get_input_id_from_metadata_or_none(metadata)))