引入依赖spring-boot-starter-cache
<!--缓存cache-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
main使用注解开启缓存功能
//开启缓存功能
@EnableCaching
需要用缓冲的地方,使用 @Cacheable注解,value定义一个变量用来保存结构,key是一个变量不要重复
@Cacheable(value = "cacheSpace", key = "#userid")