SpringCache 缓存 - @Cacheable、@CacheEvict、@CachePut、@Caching、CacheConfig 以及优劣分析

 

目录

SpringCache 缓存

环境配置

1)依赖如下

2)配置文件

3)设置缓存的 value 序列化为 JSON 格式

4)@EnableCaching 

实战开发

@Cacheable

@CacheEvict

@CachePut

@Caching

@CacheConfig

SpringCache 的优势和劣势

读操作(优势)

写操作(劣势)

总结


SpringCache 缓存


环境配置

1)依赖如下

父依赖 SpringBoot 3.2.5

        
            org.springframework.boot
            spring-boot-starter-cache
        

2)配置文件

spring:
  cache:
    type: redis
    redis:
      time-to-live: 3600000
      # key-prefix: CACHE_
      use-key-prefix: true 
     

你可能感兴趣的:(Redis深入学习,项目DEMO,缓存,java,spring)