In spring application we have two controllers i.e. controller1, controller2 and one services i.e. service1
i want to use method caching and for that i have configured spring cache.
i am caching method named method1 in service1 with @Cacheable(value = "cache1")
and for removing cache i am using @CacheEvict(value = "cache1", allEntries = true)
on another method named method2 in service1.
so caching works fine but evicting not working as i want.
so if i call method1 (cachable method) from controller1 it will cache and call method2 (cacheEvict method) from controller1 then it will remove / evict cachce properly BUT when i call method2 (cacheEvict method) from controller2 then it is NOT REMOVING / EVICTING CACHE but I WANT IT TO DO.
I want to evict / remove the cache every time the method get called doesn't matter from which controller it get called.
this is required in most cases because controller1 is for customer and controller2 is for admin. we cache methods used in controller1 and we want to remove the same cache when any update happens from controller2 i.e. admin.