Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

messagepack with redis where size of data is not big

Tags:

redis

msgpack

Redis is a data structure store but still its recommended to use message-pack (or protobuf) to serialize/deserialize data. I am kind of confuse with Messagepack on top of Redis if data chunks written to Redis is not very big.

Since, Messagepack would need packing and unpacking data as per its own protocol and for sure it will incur some cost and packed data would be store only as "string" data type on Redis.

To leverage on Redis as data structure server a thin layer can be written to read/write directly to/from redis data structure let say between C++ and Python then where exactly message-packs fits in?

Can somebody shed some light on message-pack in context of redis?

Regards,
Rahul

Disclaimer - No offence to Messagepack capability, I know its really awesome :-)

like image 370
ryadav Avatar asked Sep 18 '25 11:09

ryadav


1 Answers

There is no single answer, but I can offer a few guidelines.

  • Redis' basic data type is the string - it is binary-safe and can hold up to 0.5GB (probably more in an upcoming version).
  • Key names are strings, but you usually want to a) keep em short and b) they are the only way to access your data so hopefully legible and reconstructable.
  • Values can be strings. If the payload is already a string - no need to serialize/deserialize, just store as is. Common example: jpg or png files.
  • If your app is already using msgpack (or json or protobuff or...), you can store the serialized form.
  • Redis' Lua has built-in libs for dealing with json and msgpack.
  • There are modules (e.g. http://rejson.io) that can extend that.

I hope that helps.

Disclaimer: author of mentioned module, Redis geek and has a black belt working w/ Redis' Lua ;)

like image 166
Itamar Haber Avatar answered Sep 23 '25 13:09

Itamar Haber