I am trying to clear my cache after every 30 mins using a scheduler in SpringBoot.
@Scheduled(cron = "0 0/30 * * * ?)
@CacheEvict(value = { "cache1", "cache2" }, allEntries = true)
public void clear() {
//clears caches
}
This wasn't working initially. I referred to this post : @CacheEvict is not working in SpringBoot and started calling it from a different class and it worked.
My question is why does this happen? I couldn't find any answer over the internet.