核心代码
spring: cache: type: REDIS redis: time-to-live: 28800000 custom-ttl: { "xxx" : "1000000", "yyy": "6000000"}
@Data @Component @Configuration @ConfigurationProperties(prefix = "spring.cache.redis") public class HiteamRedisConfig { //如果为空默认为12个小时 @Value("${spring.cache.redis.time-to-live:43200000}") private Long redisKeyTtl; private HashMap<String, Long> customTtl;
注意,这里使用@Value无法注入,spring版本:2.2.6
标签:HashMap,spring,cache,redis,private,live,Spring,yml From: https://www.cnblogs.com/zhangshiwen/p/17392025.html