Code Monkey home page Code Monkey logo

Comments (5)

areyouok avatar areyouok commented on July 18, 2024 1

你这个问题是个关于 kryo 的问题,其实和 jetcache 没有关系,kryo 就是需要有反序列化的对象有默认的构造函数。

redis 不适合做通用的 java 反序列化方案,因为 json 字符串里面缺失类型信息,比如如果反射得到你的业务类有个 Object 类型的字段,反序列化时仅仅从 json 中的字符串值根本没有办法知道这是个什么类型的字段。

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on July 18, 2024

目前解决方案,给对应类创建一个无参数构造器,但是对于字段均没有 setter,也就是说 kryo5 在构造对象的时候,应该使用的是强制反射,那这种序列化方案是否比默认的 java方式好呢?另外总觉得 com.fasterxml.jackson.annotation; 注解的方式是不是更优雅?或者老师能介绍一下针对spring-redis 默认的 jackson方式和其他方式的区别么?

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on July 18, 2024

嗯嗯 老师 您说的是,目前用下来的体验就是无论是jackson还是fastjson涉及到redis序列化的地方,都比较容易产生某种“不确定性”,您这个意思一语道破,其实不确定性的根源是json字符串,我在详细了解一下 kryo吧,也是跟着框架才第一次听说,他是能避免json对 java对象的系列化困扰不?

from jetcache.

areyouok avatar areyouok commented on July 18, 2024

json不是一个 java 序列化方案,json 字符串里面缺乏类型信息,它无法保证反序列化出来的东西和原来的是一样的(除非是特别简单的对象)。

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on July 18, 2024

谢谢指点

from jetcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.