【笔记】SpringBoot通过AOP实现Cache缓存

前言

SpringBoot通过AOP实现Cache缓存

为当前方法添加缓存

methodCache:Cache名

1
2
@Cacheable("methodCache")
public void method(){}

启动清理缓存

value:清理的Cache名
allEntries:清理全部内容
beforeInvocation:清理时间在方法执行前

1
2
@CacheEvict(value = "methodCache", allEntries = true, beforeInvocation = true)
public void method(){}

完成