@CachePut or @Cacheable(value = \"CustomerCache\", key = \"#id\")
public Customer updateCustomer(Customer customer) {
sysout(\"i am inside updateCustomer\");
Yes, you are absolutely correct.
@Cacheput and @Cacheable are used in conjunction.
@Cacheable will not update the cache on every call. In order to remove the stale data, there must be a service that uses the @Cacheput that clears the stale data.
Below answer is for the ones who are using guava caching to build cache. Using guava caching, the time interval that is applied will empty the cache after a certain period of time which is not the case with @Cacheput. @Cacheput will only update the values that are stale and hence it calls the method every time to update the cache.
I hope my answer clears your question.