@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();
}*/
}
}
在Mybatis mapper xml
中<cache
eviction="FIFO"
size="512"
readOnly="true"/>
根据上面的代码,我希望缓存在会话级别并且对于单个用户是唯一的,但是当其他用户登录到系统时,我的缓存会被覆盖。如何两者都有不同的会话dashbSqlSessionFactory.getObject().getConfiguration();
Collection<Cache> caches = configuration.getCaches();
根据我的理解,不应该在其他会话中获取用户的缓存。我的代码有什么问题