0
@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(); 如何不应该在其他会话中获取用户的缓存。我的代码有问题吗

4

0 回答 0