Reputation: 23
The more I read about this, the less I know it seems :).
Just one quick question, what to use on update method if I want listAll to be refreshed with the new stuff from the update? What's safer/better practice, evict or cacheput? It's a little confusing to me, and I read 15 tabs. :D I will have delete as well, there I assume to be required just CacheEvict, right?
@Cacheable(CACHE1)
@RequestMapping(method = RequestMethod.POST)
public Object listAll(@Valid @RequestParam("status") String status) {
//code
}
@CachePut(CACHE1)
//or
@CacheEvict(value = {CACHE1}, allEntries = true)
@RequestMapping(method = RequestMethod.POST)
public Object update(@RequestBody Project project{
//code
}
Upvotes: 2
Views: 3931
Reputation: 1760
Use CachePut when you're saving an object and CacheEvict when you're deleting an object. You could conceivable just evict on save too and let the Cacheable annotation on your getters handle fetching fresh data and re-cacheing it and avoid using CachePut altogether.
Upvotes: 2