【spring boot2】第9篇:spring boot 中使用缓存

Spring Cache 的使用

Spring中定义了org.springframework.cache.Cache 和org.springframework.cache.CacheManager接口来统一不同的缓存技术

  • Cache 为缓存接口,定义了各类缓存操作
  • 在 Sprnig 中 Cache 接口提供了各种缓存的实现。如 RedisCache、EhCacheCache 、ConcurrentMapCache 等
  • 可以简单理解 Spring Cache的各种缓存形式如下图所示

快速使用 Spring Cache

  • 使用注解 @EnableCaching开启缓存注解功能
  • 常用的缓存注解

@Cacheable
@CacheEvict
@CachePut

Redis 缓存的使用

评论

暂无评论