Feature request: Python pickle support
It is fairly common for people using django to store pickled responses in redis. It would be very nice if medis supported properly displaying pickled response. I saw on npm there are several libraries that claim to support unpickling in Javascript, so maybe this isn't that crazy of an ask?
Currently, medis seems to always detect them as Viewer: JSON, Formatter: MessagePack, which makes it look like an empty dict, even though there's data there. I have to switch to Viewer: Hex, Formatter: None to be able to see anything.
Hey @dan-blanchard 👋,
Glad to add more formatters to Medis. A question is pickled data may contain tuple, classes and other data structures that can't be represented in JSON, do you have any suggestions how Medis should present them?
which makes it look like an empty dict, even though there's data there
Going to take a look as I think it's a bug that Medis detect pickled data as MessagePack.
2.8.13 fixed the wrong detection for pickle so it should default to Viewer: Hex, Formatter: None.
do you have any suggestions how Medis should present them?
Python classes can store data in two possible places: a __dict__ dictionary (which is pretty easily convertible to JSON), or in individual attributes listed in __slots__. The second format is also convertible to a dictionary/JSON-object as described here by iterating through the list of attributes and then getting the values of each.
My preference would be to display the Python classes as JSON objects, with the extra attribute __class__ set, so you could tell what class each object represented.
I am going to support custom encoders in https://github.com/luin/medis/issues/262. For pickle support, you should be able to create an encoder. LMK if there are any improvements I can do.