springboot 缓存

一、启动类增加注解

@EnableCaching

二、 service 增加 注解

@Cacheable(cacheNames = CacheName , key = "#deptId")

三、 application.yml 配置

# 缓存过期时间

cache:

# cache-names:

# myCache60:

# cache-seconds: 10

redis:

#key-prefix: aaa

# ms 毫秒 .10s

time-to-live: 10000

# 是否返回空值

cache-null-values: false

你可能感兴趣的:(缓存)