当前位置:网站首页>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));
}
边栏推荐
- 如果不知道这4种缓存模式,敢说懂缓存吗?
- Detailed explanation of platform device driver architecture in driver development
- Red hat install kernel header file
- Bypass open_ basedir
- JVM命令之- jmap:导出内存映像文件&内存使用情况
- DC-7靶机
- What EDA companies are there in China?
- Web authentication API compatible version information
- Go语学习笔记 - gorm使用 - gorm处理错误 | Web框架Gin(十)
- Nvisual network visualization
猜你喜欢

VScode进行代码补全
![Cf:c. column swapping [sort + simulate]](/img/0e/64d17980d3ec0051cdfb5fdb34e119.png)
Cf:c. column swapping [sort + simulate]

Subghz, lorawan, Nb IOT, Internet of things

Introduction to the extension implementation of SAP Spartacus checkout process

Why does the data center need a set of infrastructure visual management system

测试开发基础,教你做一个完整功能的Web平台之环境准备

cf:C. Column Swapping【排序 + 模拟】

Jinfo of JVM command: view and modify JVM configuration parameters in real time

Determine whether the file is a DICOM file

产业金融3.0:“疏通血管”的金融科技
随机推荐
生活中的开销,怎么记账合适
绕过open_basedir
Jstat pour la commande JVM: voir les statistiques JVM
话说SQLyog欺骗了我!
Jinfo of JVM command: view and modify JVM configuration parameters in real time
From "running distractor" to data platform, Master Lu started the road of evolution
The solution of a simple algebraic problem
盘点国内有哪些EDA公司?
Question 102: sequence traversal of binary tree
Things about data storage 2
Flask1.1.4 Werkzeug1.0.1 源碼分析:啟動流程
原生小程序 之 input切换 text与password类型
Understand the deserialization principle of fastjson for generics
Dc-7 target
Cf:c. column swapping [sort + simulate]
数字IC面试总结(大厂面试经验分享)
Nvisual network visualization
@Detailed differences between pathvariable and @requestparam
Forkjoin is the most comprehensive and detailed explanation (from principle design to use diagram)
cf:C. Column Swapping【排序 + 模擬】