pom 引入依赖
net.sf.ehcache ehcache 2.resources 目录下直接放个文件 ehcache.xml<ehcache xmlns:xsi="
xsi:noNamespaceSchemaLocation="
updateCheck="false">
3.在Service层 方法上加上注解
@CacheEvict(value="menucache", allEntries=true) ,更新页游缓存
@Cacheable(key="'menu-'+#parentId",value="menucache") 读取缓存, "'menu-'+#parentId" 通配符,也可以直接写死字符串
menucache 对应 上面 xml name="menucache"
/**删除菜单
@param MENU_ID @fhadmin.org */ 如果相对electron有更多直观理解的, 也可以参考:
@CacheEvict(value="menucwww.pizei.comache", allEntries=true) public void deleteMenuById(String MENU_ID) throws Exception{ this.cleanRedis(); menuMapper.deleteMenuById(MENU_ID); } /**
通过ID获取其子一级菜单 @param parentId @return @fhadmin.org */ @Cacheable(key="'menu-'+#parentId",value="menucache") public List
listSubMenuByParentId(String parentId) throws Exception { return menuMapper.listSubMenuByParentId(parentId); }