TP-62059 || Added log (#101)
* TP-62059 || Add caching to update enabled experiments. * TP-62059 || Make all the fields serializable to be dumped to Redis * TP-62059 || Refreshing enabled experiments
This commit is contained in:
@@ -7,6 +7,7 @@ import com.navi.medici.query.experiment.IExperimentQuery;
|
||||
import com.navi.medici.request.v1.LitmusExperiment;
|
||||
import com.navi.medici.util.JacksonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -15,6 +16,7 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Log4j2
|
||||
public class ExperimentMapUpdater {
|
||||
|
||||
private final CacheCommands cacheCommands;
|
||||
@@ -24,6 +26,7 @@ public class ExperimentMapUpdater {
|
||||
@Scheduled(cron = "${fetch.enabled.experiments.cron}")
|
||||
@SchedulerLock(name = "Fetch_Enabled_Experiments_Updater", lockAtMostForString = "PT10S")
|
||||
public void updateEnabledExperiments() {
|
||||
log.info("Refreshing enabled experiments in Redis cache");
|
||||
List<ExperimentEntity> experimentEntities = iExperimentQuery.findByEnabled(true);
|
||||
List<LitmusExperiment> litmusExperiments = experimentEntities.stream().map(experimentEntity -> StaticFactoryObjects.fromExperimentEntity(experimentEntity, jacksonUtils)).toList();
|
||||
cacheCommands.updateEnabledExperiments(litmusExperiments);
|
||||
|
||||
Reference in New Issue
Block a user