-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1445 from CMSgov/feature/QPPSE-314-Enable_Test_Cache
QPPSE-314: Added caching for apm entity json files
- Loading branch information
Showing
11 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gov.cms.qpp; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import com.github.benmanes.caffeine.cache.Caffeine; | ||
import gov.cms.qpp.conversion.model.validation.ApmEntityIds; | ||
import gov.cms.qpp.model.CacheType; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
public class CacheBuilder { | ||
private static Cache<CacheType, ApmEntityIds> entityIdsCache; | ||
|
||
CacheBuilder() {} | ||
|
||
public static void buildEntityIdsCache() { | ||
entityIdsCache = Caffeine.newBuilder() | ||
.expireAfterWrite(5, TimeUnit.MINUTES) | ||
.maximumSize(100) | ||
.build(); | ||
} | ||
|
||
public static ApmEntityIds getEntityIds(CacheType value) { | ||
if (entityIdsCache == null) buildEntityIdsCache(); | ||
if (entityIdsCache.getIfPresent(value) == null) { | ||
ApmEntityIds entityData = null; | ||
switch(value) { | ||
case ApmEntityId -> entityData = new ApmEntityIds("test_apm_entity_ids.json"); | ||
case ApmEntityIds -> entityData = new ApmEntityIds("test_apm_entity_ids.json","test_apm_entity_ids.json"); | ||
case ApmPcfEntityIds -> entityData = new ApmEntityIds("test_apm_entity_ids.json","test_pcf_apm_entity_ids.json"); | ||
} | ||
entityIdsCache.put(value, entityData); | ||
} | ||
return entityIdsCache.getIfPresent(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package gov.cms.qpp.model; | ||
|
||
public enum CacheType { | ||
ApmEntityId, | ||
ApmEntityIds, | ||
ApmPcfEntityIds; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters