@Autowired
@Qualifier("dashbSqlSessionFactory")
private SqlSessionFactoryBean dashbSqlSessionFactory;
@RequestMapping(value = "/clearcache", method = RequestMethod.POST)
public @ResponseBody void clearCache() throws Exception{
//System.out.println("Cache is cleared.................");
Configuration configuration = dashbSqlSessionFactory.getObject().getConfiguration();
Collection<Cache> caches = configuration.getCaches();
for (Cache cache : caches) {
/*System.out.println("cache Name: "+cache);
cache.removeObject("keyEquipmentShiftAutomatedModelData");*/
/*Lock w = cache.getReadWriteLock().writeLock();
w.lock();
try { */
cache.clear();
/*} finally {
w.unlock();
}*/
}
}
In Mybatis mapper xml
<cache
eviction="FIFO"
size="512"
readOnly="true"/>
As per above code I am expecting the cache to be at session level and unique to a single user but my cache is getting overridden when some other user logs into the system. How so as both have different sessions dashbSqlSessionFactory.getObject().getConfiguration();
Collection<Cache> caches = configuration.getCaches();
should not get cache of the user in other session as per my understanding. Is there any problem with my code