各种缓存比较

1、EhCache 是一个纯Java的进程内缓存框架,单独使用需要引入依赖:

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <version>2.10.5</version>
</dependency>

当然在spring中也可以单独使用ehcache,或者使用spring内置的缓存规范。

2、JSR107是Java caching定义的五个核心接口规范,和jdbc类似,由各大使用厂商来实现规范。要使用需要引入依赖:

<dependency>
  <groupId>javax.cache</groupId>
  <artifactId>cache-api</artifactId>
  <version>1.0.0</version>
</dependency>

3、spring3.1开始也内置了org.springframework.cache.Cache和org.springframework.cache.CacheManager接口来统一不同的缓存技术,并支持使用JCache(JSR-107)注解简化我们开发,只需要引入spring包即可;

Cache接口为缓存的组件规范定义,包含缓存的各种操作集合;

Cache接口下Spring提供了各种xxxCache的实现;如RedisCache,EhCacheCache ,
ConcurrentMapCache等;

 

posted on 2018-09-22 17:35  好好学习,天天睡觉  阅读(30)  评论(0)    收藏  举报