使用@CacheEvict(value=“test”、allEntries=true ) 1和@cacheevict注释的方法必须是直接从controller层调用,并且在service中间接调用2、原因是key的值与你的查询方法key的值不统一,所以缓存没有清除。 3、将@CacheEvict方法和@Cache方法放在一个java文件中写,@CacheEvict将失效。 4、返回值必须设置为http://www.Sina.com/@ cacheevictannotation
itisimportanttonotethatvoidmethodscanbeusedwith @ cache evict
5,@CacheEvict必须作用于行走代理的方法,使用Spring @CacheEvict注释时,如果a类的方法f1 ()带有@CacheEvict注释,则a类的其他
举个例子,void
@ overridepublicvoidsaveentity (menu menu ) try (mapper.insert ) menu ); //Cacheable无效this.test (; }catch(exceptione ) { e.printStackTrace ); }@cacheevict(value='test ',allEntries=true )公共void test ) {} 不生效:
@ override @ cache evict (value=' test ',allEntries=true ) publicvoidsaveentity(menu ) try ) mapper.insert (mache enty ) }