I would like to use Cache in my app.I set up Redis, connection is OK, cache seems to work but i'm having some trouble..First of all, can i use caching system like that with pagination ?
And my other problem is that when i use the deleteCheckConfigDeploiement method, it delete the content, but when i call getAllCheckConfigDeploiement it don't have delete the data from the cache..
@RestController@Tag(name = "EndPoint CC : ", description = "Check Configuration")@CrossOrigin()@RequestMapping("/api/v3")public class CheckConfigEndpoint { @Autowired private ICheckConfigService iCheckConfigService; @Operation(summary = "Récupération de tous les checkconfigs") @GetMapping("/check-config-deploiement") @ResponseStatus(HttpStatus.OK) @Cacheable(value = "check-config-deploiement") public PagedResponse<CheckConfigDeploiementDTO> getAllCheckConfigDeploiement( @RequestParam(value = "page", required = false, defaultValue = AppConstants.DEFAULT_PAGE_NUMBER) @Size(min = 0) Integer page, @RequestParam(value = "size", required = false, defaultValue = AppConstants.DEFAULT_PAGE_SIZE) @Size(min = 1) Integer size, @RequestParam(value = "sortBy", required = false, defaultValue = AppConstants.DEFAULT_SORT_BY) String sortBy) { return iCheckConfigService.getAllCheckConfigDeploiement(page, size, sortBy); } @Operation(summary = "Récupération des checkconfigs en fonction du namespace") @GetMapping("/check-config-deploiement/namespace/{namespace}") @ResponseStatus(HttpStatus.OK) @Cacheable(value = "check-config-deploiement", key = "#namespace") public PagedResponse<CheckConfigDeploiementDTO> getAllCheckConfigDeploiement( @PathVariable String namespace, @RequestParam(value = "page", required = false, defaultValue = AppConstants.DEFAULT_PAGE_NUMBER) @Size(min = 0) Integer page, @RequestParam(value = "size", required = false, defaultValue = AppConstants.DEFAULT_PAGE_SIZE) @Size(min = 1) Integer size, @RequestParam(value = "sortBy", required = false, defaultValue = AppConstants.DEFAULT_SORT_BY) String sortBy) { return iCheckConfigService.getCheckConfigDeploiementByNamespace( namespace, page, size, sortBy); } @Operation(summary = "Récupération des checkconfigs en fonction des paramètres") @GetMapping("/check-config-deploiement/namespace/{namespace}/composant/{composant}") @ResponseStatus(HttpStatus.OK) @Cacheable(value = "check-config-deploiement",key="#namespace, #composant") public PagedResponse<CheckConfigDeploiementDTO> getAllCheckConfigDeploiement( @PathVariable String namespace, @PathVariable String composant, @RequestParam(value = "page", required = false, defaultValue = AppConstants.DEFAULT_PAGE_NUMBER) @Size(min = 0) Integer page, @RequestParam(value = "size", required = false, defaultValue = AppConstants.DEFAULT_PAGE_SIZE) @Size(min = 1) Integer size, @RequestParam(value = "sortBy", required = false, defaultValue = AppConstants.DEFAULT_SORT_BY) String sortBy) { return iCheckConfigService .getCheckConfigDeploiementByNamespaceAndComposant( namespace, composant, page, size, sortBy); } @Operation(summary = "Récupération des checkconfigs en fonction des paramètres") @GetMapping("/check-config-deploiement/namespace/{namespace}/date/{dateDebut}/{dateFin}") @ResponseStatus(HttpStatus.OK) @Cacheable(value = "check-config-deploiement", key = "#namespace, #dateDebut, #dateFin") public PagedResponse<CheckConfigDeploiementDTO> getAllCheckConfigDeploiement( @PathVariable String namespace, @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date dateDebut, @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date dateFin, @RequestParam(value = "page", required = false, defaultValue = AppConstants.DEFAULT_PAGE_NUMBER) @Size(min = 0) Integer page, @RequestParam(value = "size", required = false, defaultValue = AppConstants.DEFAULT_PAGE_SIZE) @Size(min = 1) Integer size, @RequestParam(value = "sortBy", required = false, defaultValue = AppConstants.DEFAULT_SORT_BY) String sortBy) { return iCheckConfigService .getCheckConfigDeploiementByNamespaceAndLogCreatedAtBetween( namespace, dateDebut, dateFin, page, size, sortBy); } @Operation(summary = "Suppression d'un CheckConfig") @DeleteMapping("/check-config-deploiement/{id}") @ResponseStatus(HttpStatus.NO_CONTENT) @CacheEvict(value = "check-config-deploiement", key = "#id") public void deleteCheckConfigDeploiement(@PathVariable Integer id) { iCheckConfigService.deleteCheckConfigDeploiement(id); } @Operation(summary = "Insertion d'un CheckConfig") @PostMapping("/check-config-deploiement") @ResponseStatus(HttpStatus.CREATED) @CacheEvict(value = "check-config-deploiement", allEntries = true) public CheckConfigDeploiement saveCheckConfigDeploiement( @Valid @RequestBody CheckConfigDeploiementDTO checkConfigDeploiementDTO) { return iCheckConfigService.saveCheckConfig(checkConfigDeploiementDTO); } @Operation(summary = "Update d'un CheckConfig") @PutMapping("/check-config-deploiement/{id}") @ResponseStatus(HttpStatus.OK) @CacheEvict(value = "check-config-deploiement", key = "#id") public CheckConfigDeploiement updateCheckConfigDeploiement( @PathVariable Integer id, @Valid @RequestBody CheckConfigDeploiementDTO checkConfigDeploiementDTO) { return iCheckConfigService.updateCheckConfigDeploiement(id, checkConfigDeploiementDTO); }}