From 0496b343b10311acca56e9305fa008214512504d Mon Sep 17 00:00:00 2001 From: Mirco Nasuti <mirco.nasuti@chuv.ch> Date: Thu, 10 Nov 2016 12:22:36 +0100 Subject: [PATCH] add caching to experiments --- src/main/java/eu/hbp/mip/controllers/ExperimentApi.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java b/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java index eef1bfe88..ffbe68be0 100644 --- a/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ExperimentApi.java @@ -14,6 +14,9 @@ import eu.hbp.mip.repositories.ModelRepository; import eu.hbp.mip.utils.JSONUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -72,6 +75,8 @@ public class ExperimentApi { @ApiOperation(value = "Send a request to the workflow to run an experiment", response = Experiment.class) + @CachePut("exp") + @CacheEvict(value = "exps", allEntries = true) @RequestMapping(method = RequestMethod.POST) public ResponseEntity<String> runExperiment(@RequestBody ExperimentQuery expQuery) { LOGGER.info("Run an experiment"); @@ -104,6 +109,7 @@ public class ExperimentApi { } @ApiOperation(value = "get an experiment", response = Experiment.class) + @Cacheable("exp") @RequestMapping(value = "/{uuid}", method = RequestMethod.GET) public ResponseEntity<String> getExperiment(@ApiParam(value = "uuid", required = true) @PathVariable("uuid") String uuid) { LOGGER.info("Get an experiment"); @@ -171,6 +177,7 @@ public class ExperimentApi { } @ApiOperation(value = "list experiments", response = Experiment.class, responseContainer = "List") + @Cacheable("exps") @RequestMapping(value = "/mine", method = RequestMethod.GET, params = {"maxResultCount"}) public ResponseEntity<String> listExperiments( @ApiParam(value = "maxResultCount", required = false) @RequestParam int maxResultCount @@ -196,6 +203,7 @@ public class ExperimentApi { } @ApiOperation(value = "List available methods and validations", response = String.class) + @Cacheable("methods") @RequestMapping(path = "/methods", method = RequestMethod.GET) public ResponseEntity<String> listAvailableMethodsAndValidations() throws IOException { LOGGER.info("List available methods and validations"); -- GitLab