Skip to content

Commit

Permalink
Don't use the Cohorts cache when the retain Cohort covariates option …
Browse files Browse the repository at this point in the history
…is switched on

# Conflicts:
#	src/main/java/org/ohdsi/webapi/cohortdefinition/CohortGenerationRequestBuilder.java
  • Loading branch information
alex-odysseus committed Nov 15, 2024
1 parent 787e805 commit 3f31277
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3f31277

Please sign in to comment.