redis使用fastjson2序列化
时间: 2023-10-24 18:58:47 浏览: 128
在Redis中使用FastJson2JsonRedisSerializer进行序列化是一种常见的做法。通过配置RedisConfig类,可以将FastJson2JsonRedisSerializer作为RedisTemplate的序列化器。在RedisConfig类中,通过@Bean注解创建了一个RedisSerializer的实例,并将其设置为RedisTemplate的keySerializer、valueSerializer、hashKeySerializer和hashValueSerializer。这样就可以使用FastJson对Redis中的数据进行序列化和反序列化了。同时,还需要注意在使用@Cacheable注解时,key属性只能传入String类型的值,因为使用了StringRedisSerializer作为key的序列化器。\[2\]\[3\]
#### 引用[.reference_title]
- *1* [Redis使用FastJson序列化/FastJson2JsonRedisSerializer](https://blog.csdn.net/moshowgame/article/details/83246363)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [SpringBoot之redis使用FastJSON自定义序列化](https://blog.csdn.net/qq_37892957/article/details/89303942)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [阿里FastJson2JsonRedisSerializer.java作为内部类强化RedisConfig的序列化实现](https://blog.csdn.net/as4589sd/article/details/104214206)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文