缓存穿透 :查询数据为空。 解决:spring.cache.redis.cache-null-values=true
缓存击穿: 大量并发请求 请求一个正好过期的缓存数据,解决:加锁 sync=true;
缓存雪崩:大量key缓存数据同一时间正好过期,解决:给key添加随机过期时间。加上过期时间 在配置文件添加 spring.cache.redis.time-to-live=360000
设置随机过期时间
创建RedisConfigCacheManager类
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.cache.*;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data