Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Serialization methods in redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Serialize the value of redis using the following serialization method:

1:JdkSerializationRedisSerializer:

2:GenericJackson2JsonRedisSerializer

3:StringRedisSerializer

4:GenericFastJsonRedisSerializer

Found that only 4:GenericFastJsonRedisSerializer, it is best to use, do not report errors

The following is a brief introduction one by one

1:JdkSerializationRedisSerializer:

Serializing the java object encounters the following error:

DefaultSerializer requires a Serializable payload but received an object of type [com.everestfortune.cf.bean.CaseInfoBean]

Switch to logDB

Reason: Bean serialized with JdkSerializationRedisSerializer must implement the Serializable interface

2:GenericJackson2JsonRedisSerializer

The following error was encountered when obtaining the data in redis:

2019-04-26 11 c.e.cf.controller.ApplyController 26 14 ERROR 11656-[nio-9076-exec-7] c.e.cf.controller.ApplyController

: redis failed to obtain data. Mes=Could not read JSON: Cannot construct instance of `java.time.LocalDate`

(no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

Reason: LocalDate, a new class added by java8, cannot be recognized by GenericJackson2JsonRedisSerializer serialization.

3:StringRedisSerializer

Bean cannot be serialized, only data of string type can be serialized. If value is of string type, you can serialize it in this way.

4: GenericFastJsonRedisSerializer:

No problem has been found so far. It's easy to use.

These are the details of which redis serialization methods, please pay more attention to other related articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report