I have a class like below:
public class Person { public String name; public String age; }
I am a bit confused over the approach of saving a Map of Perons into Redis:
Should I go for java serialized/deserialized object approach or should i try converting to JSON and then storing and vice versa.
Any thoughts on below mentioned points:
Compression : Stream vs Data
Which compression should we go for Though DATA compression seems a bit difficult(not much benificial) as we are using Redish Hash
Some of the assumptions are:
The RedisJSON module provides JSON support for Redis. RedisJSON lets you store, update, and retrieve JSON values in a Redis database, similar to any other Redis data type. RedisJSON also works seamlessly with RediSearch to let you index and query JSON documents.
RedisJSON is a high-performance NoSQL document store that allows developers to build modern applications. It provides native APIs to ingest, index, query, and run full-text search on JSON documents both on-premises and as a managed service in the cloud.
Serialization/Deserializarion with Spring Data Redis(SDR)There are several prepared implemented classes responsible for serialization/deserialization for some kind of types provided by RedisTemplate by default. In case of specific requirement you can implement your custom serializer.
You should consider using MessagePack as it is full compatible with Redis and Lua, it is a great compression on JSON: http://msgpack.org/
It implies some Lua code to compress and uncompress, but the cost should be small. Here is an example: http://gists.fritzy.io/2013/11/06/store-json-as-msgpack
There is a small benchmark which lacks data: https://gist.github.com/muga/1119814
Still it should be a great option for you, as you can use it in different languages, fully supported on redis, and it is based on JSON.
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