当前位置:网站首页>Redisl garbled code and expiration time configuration
Redisl garbled code and expiration time configuration
2022-07-07 06:09:00 【Tunan】
/** * 1 Minutes expired * @param connectionFactory * @return */
@Bean
public RedisCacheManager cacheManager1Minute(RedisConnectionFactory connectionFactory) {
RedisCacheConfiguration config = instanceConfig(60L);
return RedisCacheManager.builder(connectionFactory)
.cacheDefaults(config)
.transactionAware()
.build();
}
/** * The default is 1 Hours * @param connectionFactory * @return */
@Bean
@Primary
public RedisCacheManager cacheManager1Hour(RedisConnectionFactory connectionFactory) {
RedisCacheConfiguration config = instanceConfig(3600L);
return RedisCacheManager.builder(connectionFactory)
.cacheDefaults(config)
.transactionAware()
.build();
}
/** * 1 Days overdue * @param connectionFactory * @return */
@Bean
public RedisCacheManager cacheManager1Day(RedisConnectionFactory connectionFactory) {
RedisCacheConfiguration config = instanceConfig(3600 * 24L);
return RedisCacheManager.builder(connectionFactory)
.cacheDefaults(config)
.transactionAware()
.build();
}
private RedisCacheConfiguration instanceConfig(Long ttl) {
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.registerModule(new JavaTimeModule());
// Get rid of all kinds of @JsonSerialize Interpretation of annotations
objectMapper.configure(MapperFeature.USE_ANNOTATIONS, false);
// Serialize only for non null values
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
// Serialize the type to the property json In a string
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance ,
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
return RedisCacheConfiguration.defaultCacheConfig()
.entryTtl(Duration.ofSeconds(ttl))
//.disableCachingNullValues()
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(jackson2JsonRedisSerializer));
}
边栏推荐
- How much do you know about clothing ERP?
- Digital IC interview summary (interview experience sharing of large manufacturers)
- 【SQL实战】一条SQL统计全国各地疫情分布情况
- 404 not found service cannot be reached in SAP WebService test
- [FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
- Add salt and pepper noise or Gaussian noise to the picture
- STM32 key state machine 2 - state simplification and long press function addition
- 牙齿干细胞的存储问题(未完待续)
- Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
- 产业金融3.0:“疏通血管”的金融科技
猜你喜欢
PowerPivot - DAX (function)
如何在Touch Designer 2022版中设置解决Leap Motion不识别的问题?
C note 13
目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
深度聚类:将深度表示学习和聚类联合优化
Peripheral driver library development notes 43: GPIO simulation SPI driver
老板总问我进展,是不信任我吗?(你觉得呢)
693. 行程排序
为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾
[cloud native] what is the microservice architecture?
随机推荐
软件测试知识储备:关于「登录安全」的基础知识,你了解多少?
[SQL practice] a SQL statistics of epidemic distribution across the country
成为资深IC设计工程师的十个阶段,现在的你在哪个阶段 ?
Say sqlyog deceived me!
Digital IC interview summary (interview experience sharing of large manufacturers)
如果不知道这4种缓存模式,敢说懂缓存吗?
On the difference between FPGA and ASIC
PowerPivot - DAX (function)
Question 102: sequence traversal of binary tree
693. 行程排序
驱动开发中platform设备驱动架构详解
JVM命令之 jinfo:实时查看和修改JVM配置参数
@pathvariable 和 @Requestparam的详细区别
JVM monitoring and diagnostic tools - command line
980. Different path III DFS
mac版php装xdebug环境(m1版)
Ten stages of becoming a Senior IC Design Engineer. What stage are you in now?
Swagger3 configuration
JVM监控及诊断工具-命令行篇
Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)