The following works (results in the evict being performed):
fooController {
@ApiEndpoint
public delete(id) {
fooService.deleteFoo(id)
}
}
fooService {
@CacheEvict(value = "cache1", key = "#id")
public void deleteFoo(Long id) {
//delete logic here
}
}
But this does not work (nothing is evicted from the cache):
fooController {
@ApiEndpoint
public delete(name) {
fooService.deleteFoo2(name)
}
}
fooService {
public void deleteFoo2(String name) {
//delete logic here
deleteFoo(name.getId())
}
@CacheEvict(value = "cache1", key = "#id")
public void deleteFoo(Long id) {
//delete logic here
}
}
Why are my @CacheEvict annotations only called when the method is called straight from the controller?
I'm using Redis as the caching mechanism.