Caso eu tenha dois ou mais metodos que estão anotados com o @Cacheable e eu deseje limpar eles nos metodos como farei isso.
@PostMapping
@CacheEvict(value = LISTA_TOPICOS,allEntries = true)
public ResponseEntity<TopicoDto> cadastrar(@RequestBody @Valid TopicoForm topicoForm, UriComponentsBuilder uriComponentsBuilder){
Topico topico = topicoForm.converter(cursoRepository);
topicoRepository.save(topico);
URI uri= uriComponentsBuilder.path("/topicos/{id}").buildAndExpand(topico.getId()).toUri();
return ResponseEntity.created(uri).body(new TopicoDto(topico));
}
@GetMapping("/{id}")
@Cacheable(value = LISTA_TOPICO_DETALHADO)
public DetalhesDoTopicoDto detalhar(@PathVariable Long id) throws ExceptionMessage {
if(!topicoRepository.findById(id).isPresent()){
throw new ExceptionMessage();
}
return new DetalhesDoTopicoDto(topicoRepository.getOne(id));
}
@PutMapping("/{id}")
@Transactional
@CacheEvict(value = LISTA_TOPICOS,allEntries = true)
public ResponseEntity<TopicoDto> atualizar(@PathVariable Long id, @RequestBody @Valid AtualizarTopicoForm topicoForm) throws ExceptionMessage {
Topico topico = topicoForm.atualizer(id,topicoRepository);
return ResponseEntity.ok(new TopicoDto(topico));