1、Spring缓存支持
1.1、Spring定义了org.springframework.cache.CacheManager类、org.springframework.cache.Cache类接口来统一不同的缓存技术;
CacheManager:
Spring提供的 各种缓存技术 抽象接口;
Cache:
Cache接口包含 缓存的各种操作(add,remove,get);
1.2、Spring支持的CacheManager
a,在使用任意一个CacheManager的实现类时,需要注册实现的CacheManager的Bean;
1.3、声明式缓存注解
Spring提供了4个注解 声明缓存规则:
1.4、开启声明式缓存支持
只需要 在配置类上 使用@EnableCaching注解即可;
package com.an.cache; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Configuration; /** * @description: * @author: anpeiyong * @date: Created in 2019/11/27 10:29 * @since: */ @Configuration @EnableCaching public class CacheConfig { }
原文:https://www.cnblogs.com/anpeiyong/p/11940300.html