I have two services
class CustomerService {
public void removeCustomer(int customerId) {...}
}
class OrderService {
@Cacheable("orders")
public List<Order> getOrders() {...}
}
On removeCustomer()
I want the orders
cache to be evicted, since the result has changed (the orders of the removed customers are gone). How can I do this with Spring's caching?
You can use @CacheEvict annotation for the same. Please refer to the below link for details
You can find example at