From 3f312772fd1f0aac158bb21e71cec81de0d42a9d Mon Sep 17 00:00:00 2001 From: alex-odysseus Date: Thu, 24 Oct 2024 15:17:37 +0200 Subject: [PATCH] Don't use the Cohorts cache when the retain Cohort covariates option is switched on # Conflicts: # src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java --- .../cohortdefinition/CohortGenerationRequestBuilder.java | 3 +++ .../ohdsi/webapi/generationcache/GenerationCacheHelper.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java b/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java index 0cff180a0..b88a66148 100644 --- a/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java +++ b/src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java @@ -71,5 +71,8 @@ public CohortGenerationRequest buildWithRetainCohortCovariates() { return new CohortGenerationRequest(expression, source, sessionId, targetId, targetSchema, retainCohortCovariates, cohortId); + + public boolean hasRetainCohortCovariates() { + return retainCohortCovariates != null ? retainCohortCovariates.booleanValue() : false; } } diff --git a/src/main/java/org/ohdsi/webapi/generationcache/GenerationCacheHelper.java b/src/main/java/org/ohdsi/webapi/generationcache/GenerationCacheHelper.java index e671fb8ca..32cca80ac 100644 --- a/src/main/java/org/ohdsi/webapi/generationcache/GenerationCacheHelper.java +++ b/src/main/java/org/ohdsi/webapi/generationcache/GenerationCacheHelper.java @@ -51,8 +51,9 @@ public CacheResult computeCacheIfAbsent(CohortDefinition cohortDefinition, Sourc return transactionTemplateRequiresNew.execute(s -> { log.info("Retrieves or invalidates cache for cohort id = {}", cohortDefinition.getId()); GenerationCache cache = generationCacheService.getCacheOrEraseInvalid(type, designHash, source.getSourceId()); - if (cache == null) { - log.info("Cache is absent for cohort id = {}. Calculating with design hash = {}", cohortDefinition.getId(), designHash); + if (cache == null || requestBuilder.hasRetainCohortCovariates()) { + String messagePrefix = (cache == null ? "Cache is absent" : "Cache will not be used because the retain cohort covariates option is switched on"); + log.info(messagePrefix + " for cohort id = {}. Calculating with design hash = {}", cohortDefinition.getId(), designHash); // Ensure that there are no records in results schema with which we could mess up generationCacheService.removeCache(type, source, designHash); CohortGenerationRequest cohortGenerationRequest = requestBuilder