diff --git a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java index 71c3f1460ea264f6e60541a98c50a82a40f3803d..650116b1fd93c2bc9336f70221d1342942c2f7a1 100644 --- a/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ArticlesApi.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.annotation.Caching; import org.springframework.context.annotation.Scope; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -82,7 +83,12 @@ public class ArticlesApi { @ApiOperation(value = "Create an article") @ApiResponses(value = { @ApiResponse(code = 201, message = "Article created") }) @CachePut(value = "Article", key = "#article.getSlug() + #root.target") - @CacheEvict(value = "Articles", allEntries = true) + @Caching(evict = { + @CacheEvict(value = "Articles", key = "'false' + 'draft' + #root.target"), + @CacheEvict(value = "Articles", key = "'false' + 'published' + #root.target"), + @CacheEvict(value = "Articles", key = "'true' + 'draft' + #root.target"), + @CacheEvict(value = "Articles", key = "'true' + 'published' + #root.target") + }) @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Void> addAnArticle( @RequestBody @ApiParam(value = "Article to create", required = true) @Valid Article article @@ -173,7 +179,12 @@ public class ArticlesApi { @ApiOperation(value = "Update an article") @ApiResponses(value = { @ApiResponse(code = 204, message = "Article updated") }) @CachePut(value = "Article", key = "#slug + #root.target") - @CacheEvict(value = "Articles",allEntries = true) + @Caching(evict = { + @CacheEvict(value = "Articles", key = "'false' + 'draft' + #root.target"), + @CacheEvict(value = "Articles", key = "'false' + 'published' + #root.target"), + @CacheEvict(value = "Articles", key = "'true' + 'draft' + #root.target"), + @CacheEvict(value = "Articles", key = "'true' + 'published' + #root.target") + }) @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAnArticle( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug, diff --git a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java index 2df27612c3a98c737f247c7e5b27b6faf1ed133d..1cce4e2526a3fb3e432e57e4df71c8a6da98ebed 100644 --- a/src/main/java/eu/hbp/mip/controllers/ModelsApi.java +++ b/src/main/java/eu/hbp/mip/controllers/ModelsApi.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; import org.springframework.cache.annotation.Cacheable; +import org.springframework.cache.annotation.Caching; import org.springframework.context.annotation.Scope; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -108,7 +109,12 @@ public class ModelsApi { @ApiOperation(value = "Create a model", response = Model.class) @ApiResponses(value = { @ApiResponse(code = 201, message = "Model created") }) @CachePut(value = "Model", key = "#model.getSlug() + #root.target") - @CacheEvict(value = "Models", allEntries = true) + @Caching(evict = { + @CacheEvict(value = "Models", key = "'false' + 'false' + #root.target"), + @CacheEvict(value = "Models", key = "'false' + 'true' + #root.target"), + @CacheEvict(value = "Models", key = "'true' + 'false' + #root.target"), + @CacheEvict(value = "Models", key = "'true' + 'true' + #root.target") + }) @RequestMapping(method = RequestMethod.POST) public ResponseEntity<Model> addAModel( @RequestBody @ApiParam(value = "Model to create", required = true) Model model @@ -228,7 +234,12 @@ public class ModelsApi { @ApiOperation(value = "Update a model", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 204, message = "Model updated") }) @CachePut(value = "model", key = "#slug + #root.target") - @CacheEvict(value = "Models", allEntries = true) + @Caching(evict = { + @CacheEvict(value = "Models", key = "'false' + 'false' + #root.target"), + @CacheEvict(value = "Models", key = "'false' + 'true' + #root.target"), + @CacheEvict(value = "Models", key = "'true' + 'false' + #root.target"), + @CacheEvict(value = "Models", key = "'true' + 'true' + #root.target") + }) @RequestMapping(value = "/{slug}", method = RequestMethod.PUT) public ResponseEntity<Void> updateAModel( @ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,