What library or method can I use in Python so I can take a string and compress it to be stored inside of Redis? The objective is to reduce the size of some strings (cPickle
d objects) as they go through the wire, at the cost of some computational power.
I believe that the resulting object has to be of type str
before storage. I am using the redis-py
library.
Thanks very much!
I recommend you zlib:
import zlib
compressedString = zlib.compress(originalString, 9) # Compress at level 9
decompressedString = zlib.decompress(compressedString)
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