• 欢迎光临~

Spring Cache

开发技术 开发技术 2022-08-29 次浏览

Spring Cache是一个框架,实现了基于注解的缓存功能,只需要简单的加一个注解,就能实现缓存功能。
Spring Cache提供了一层抽象,底层可以切换不同的cache实现,具体就是通过CacheManager接口来统一不同的缓存技术。
CacheManager是Speing提供的各种缓存技术抽象接口。

针对不同的缓存技术需要实现不用的CacheManager:

CacheManager 描述
EhCacheCacheManager 使用EhCache作为缓存技术
GuavaCacheManager 使用Google的GuavaCache作为缓存技术
RedisCacheManager 使用Redis作为缓存技术

常用注解

Spring Cache

使用方式

Spring Cache

@Cacheable注解参数:cacheNames 表示:key的前缀     key 表示:一个key的唯一标识
cacheNames+key 是一个完整的key值   unless 表示:这个条件不成立时加入缓存。

 Spring Cache

 Spring Cache 上下文数据

 Spring Cache 

程序员灯塔
转载请注明原文链接:Spring Cache
喜欢 (0)