1 Spring Cache
Spring Cache是Spring针对Spring应用,给出的一整套应用缓存解决方案。
Spring Cache本身并不提供缓存实现,而是通过统一的接口和代码规范,配置、注解等使你可以在Spring应用中使用各种Cache,而不用太关心Cache的细节。通过Spring Cache ,你可以方便的使用
各种缓存实现,包括ConcurrentMap,Ehcache 2.x,JCache,Redis等。
2 Spring Cache API
Spring Cache接口
Spring 中关于缓存的定义,包括在接口org.springframework.cache.Cache 中,它主要提供了如下方法
// 根据指定key获取值
<T> T get(Object key, Class<T> type)
// 将指定的值,根据相应的key,保存到缓存中
void put(Object key, Object value);
// 根据键,回收指定的值
void evict(Object key)
从定义中不难看着,Cache 事实上就是一个key