首页 > 编程知识 正文

案例上手spring全家桶,springcache多级缓存

时间:2023-05-03 07:57:51 阅读:17519 作者:636

使用@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 ) }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。