Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATAREDIS-392 - Add Gerneric Jackson2 RedisSerializer. #145

Closed
wants to merge 2 commits into from

Conversation

christophstrobl
Copy link
Member

We introduced GenericJackson2JsonRedisSerializer holding a preconfigured ObjectMapper which writes class type informations into the JSON structure. This enables polymorphic deserialization and allows RedisCacheManager to operate upon a RedisTemplate storing data in JSON format, which had until this only been possible using the JdkSerializer.


Alternative Implementation for #136

*
* @param mapper must not be {@literal null}.
*/
public GenericJackson2JsonRedisSerializer(ObjectMapper mapper) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an additional overload that takes an ObjectMapper and the type key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which benefit would we offer by adding that one? If we offer that we'd need to take care of potential configuration already done on the mapper before handing it to the serializer. I'd rather leave it completely to the user to configure the mapper when using this option.

We introduced GenericJackson2JsonRedisSerializer holding a preconfigured ObjectMapper which writes Class type informations into the JSON structure. This enables polymorphic deserialization and allows RedisCache manager to operate upon a RedisTemplate storing data in JSON format, which had until this only been possible using the Jdk Serializer.
@kgdngitfk
Copy link

I have read the source code and the data store into redis,I think the GenericJackson2JsonRedisSerializer
seri serialize(Object val) convert val to JSON with the key "@Class": "com.xx.xx.Data" which value use for
deserialize() to the corresponding java Type,isn't it?

@christophstrobl
Copy link
Member Author

@kgdngitfk yes. It's using an ObjectMapper having defaultTyping enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants