we are currently writing a REST service with jax-rs
where we are caching the DB entities(javax.persistence.Entity
) i.e.object representation of a table in database, in the redis server. Before even putting the objects to redis we serialize the objects to json
via jackson
and when we need the entity object we deserialize it after fetching from redis.
I want to know whether there is a faster/more performant way of doing serialization and deserialization. I am ok if somebody suggest a more performant way without converting the object to human readable format like json and also i don't want the intra language interoperability.
Please let me know if somebody needs some more details on this. Thanks.
There are many, many libraries for serializing Objects in Java. JVM Serializers benchmark, for example, includes two dozens or so.
Couple of things that do help you get even faster serialization, if that is the primary concern:
Smile
or CBOR
with Jackson (https://github.com/FasterXML/jackson-dataformat-smile, https://github.com/FasterXML/jackson-dataformat-cbor). These are not developer-readable, but take up less space, are bit faster to process, and can be read from other languages too (i.e. not Java specific)For JSON, Jackson is amongst fastest, and while there are some cases where others (Boon, fastjson) can be faster, you really need to benchmark your particular use case to know if yours is one. But even then, difference is unlikely to be huge.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With