Spring Cache
Spring Cache 介绍
Spring Cache 是一个框架,实现了基于注解的缓存功能,只需要简单的加一个注解,就能实现缓存功能。
Spring Cache 提供了一层抽象,底层可以切换不同的chche 实现。具体就是通过CacheManager 接口来统一不同的缓存技术。ChcheManager 是Spring 提供的各种缓存技术抽象接口。
针对不同的缓存技术,需要实现不同的CacheManager:
CacheManager | 描述 |
EhCacheCacheManager | 使用EhCache作为缓存技术 |
GuavaCacheManager | 使用Google的GuavaCache作为缓存技术 |
RedisCacheManager | 使用Redis作为缓存技术 |
通过Spring Cache 可以简化缓存操作的代码。相比通过redis来实现缓存,更加方便方便快捷。