/* ******************************************載入緩存開始************************************************** */
/**
* 保存部門信息
* 獲取緩存信息
*
* @param dept
* @return
*/
@CachePut(cacheNames = "top.yangbuyi.system.service.impl.DeptServiceImpl", key = "#result.id")
@Override
public Dept saveDept(Dept dept) {
// mq insert會返回一個 添加后的id
this.deptMapper.insert(dept);
log.info(dept.getTitle() + "节芥,改信息已存入緩存");
return dept;
}
/**
* 修改部門
* 獲取緩存信息
*
* @param dept
* @return
*/
@CachePut(cacheNames = "top.yangbuyi.system.service.impl.DeptServiceImpl", key = "#result.id")
@Override
public Dept updateDept(Dept dept) {
this.deptMapper.updateById(dept);
log.info(dept.getTitle() + ",已修改緩存當(dāng)中的信息");
return dept;
}
/**
* 重寫 mq 方法 獲取緩存信息
*
* @param id
* @return
*/
@Cacheable(cacheNames = "top.yangbuyi.system.service.impl.DeptServiceImpl", key = "#id")
@Override
public Dept getById(Serializable id) {
log.info(id + "裂明,已從緩存當(dāng)中獲取");
return super.getById(id);
}
/**
* 重寫 mq 刪除方法
*
* @param id
* @return
*/
@CacheEvict(cacheNames = "top.yangbuyi.system.service.impl.DeptServiceImpl", key = "#id")
@Override
public boolean removeById(Serializable id) {
log.info(id + ":已將該信息從緩存當(dāng)中刪除");
return super.removeById(id);
}
/* ******************************************載入緩存結(jié)束************************************************** */
/* ******************************************清理全部緩存開始************************************************** */
@Override
@CacheEvict(value = "top.yangbuyi.system.service.impl.DeptServiceImpl", allEntries = true)
public void clearAllRedisDB() {
log.info("指定清理部門Redis緩存槽中的所有對象....");
}
/* ******************************************清理全部緩存結(jié)束************************************************** */
作者:楊不易
鏈接:http://www.reibang.com/nb/45397607
來源:簡書
著作權(quán)歸作者所有偶芍。商業(yè)轉(zhuǎn)載請聯(lián)系作者獲得授權(quán),非商業(yè)轉(zhuǎn)載請注明出處取胎。