当前位置:网站首页>Customized redistemplate in redis
Customized redistemplate in redis
2022-06-11 02:16:00 【Java Xiaohao】
Self defined RedisTemplate
@Configuration
public class RedisConfig {
@Bean
@SuppressWarnings("all")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
// For our own development convenience , It is usually used directly <String, Object>
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(factory);
// Json The serialization configuration of
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer;
jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper(); // ObjectMapper Transference
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
// String The serialization configuration of
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
// Configure the specific serialization method
// key use String How to serialize
template.setKeySerializer(stringRedisSerializer);
// hash Of key Also used String Amount serialization method
template.setHashKeySerializer(stringRedisSerializer);
// value The serialization method of is jackson
template.setValueSerializer(jackson2JsonRedisSerializer);
// hash Of value The serialization method adopts Jackson
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
}
边栏推荐
- 软件测试面试复盘:技术面没有难倒我,hr面却是一把挂
- 腾讯面试官曰Mysql架构的内部模块索引原理及性能优化思路谁会?
- Can the soft exam certificate be settled in Shanghai? Many people don't know
- 力扣刷题篇——哈希表
- Task07: double pointer
- Within one month, the broadcasting volume has increased by 9million, and station B has three traffic growth passwords!
- Task02: linked list
- Record the actual record of my question brushing
- Introduction and practice of QT tcp/udp network protocol (II) UDP communication
- 软件测试是否需要掌握编程能力
猜你喜欢

NFT insider 61:animoca brands holds US $1.5 billion of encrypted assets in 340 investments

SSH配置密钥登录时需要注意私钥是否设置了密码(passphrase)

FB02编辑Coding Block字段

Find - (sequential search)

浅析直播间海量聊天消息的架构设计难点

Task05: tree

Task07: double pointer

软测人都该知道的七大原则

Internet of things final assignment - sleep quality detection system (refined version)

QT database learning notes (II) QT operation SQLite database
随机推荐
【并行与分布式系统】Cache学习
AI fanaticism | come to this conference and work together on the new tools of AI!
贵金属白银行情走势图缘何强势?
Analysis of common ADB commands
Merge sort ()
In the past 10 years, from zero foundation testing to test architect, he has made himself successful
Secret
ACM tutorial - heap sorting
FB02编辑Coding Block字段
npm ERR Fix the upstream dependency conflict, or retry
Orcale driver
[3.delphi common components] 6 scroll bar
Talk about an annotation implementation interface retry
Introduction and practice of QT tcp/udp network protocol (supplementary)
InfoQ geek media's 15th anniversary solicitation | in depth analysis of container runtime Technology
Task03: stack
Task07: double pointer
[Qt] Erreur: qapplication: No such file or directory Solution
1031. 两个非重叠子数组的最大和
Task06: bit operation