Use the following serialization method for redis value:
1: JdkSerializationRedisSerializer: (Recommended learning: Redis Video tutorial)
2: GenericJackson2JsonRedisSerializer
3: StringRedisSerializer
4: GenericFastJsonRedisSerializer
Found only 4: GenericFastJsonRedisSerializer, the best to use, not Error reporting
The following is a brief introduction one by one
1: JdkSerializationRedisSerializer:
Serializing java objects encounters the following error reporting :
DefaultSerializer requires a Serializable payload but received an object of type [com.everestfortune.cf.bean.CaseInfoBean]
Switch to logDB
Reason: Beans serialized using JdkSerializationRedisSerializer must implement the Serializable interface
2: GenericJackson2JsonRedisSerializer
Obtaining data from redis encountered the following error:
2019-04-26 11:26:41.510 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 is a new class in java8, and the GenericJackson2JsonRedisSerializer serialization method cannot be recognized
3: StringRedisSerializer
cannot serialize beans, only characters. String type data, if the values are all string types, can be serialized in this way
4: GenericFastJsonRedisSerializer:
No problems have been found so far, it is very easy to use
For more Redis-related technical articles, please visit the Redis Getting Started Tutorial column to learn!
The above is the detailed content of What are the redis serialization methods?. For more information, please follow other related articles on the PHP Chinese website!