Home > Database > Redis > body text

What are the redis serialization methods?

(*-*)浩
Release: 2019-11-30 09:26:01
Original
11088 people have browsed it

What are the redis serialization methods?

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]
Copy after login

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
Copy after login

: 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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template