December 17th, 2012, 07:56 AM
Data stored by pylibmc cannot be uncompressed in php memcached
We have an application where we are using python to store lots of data in memcached. We are using pylibmc in python and on php side we are using php-memcached library. Everything else is fine except when compression comes into play. This is how data is compressed in python
checking in telnet we see some garbled value, which means it was compressed. Now reading it in php.
mem = pylibmc.Client(['10.90.15.104:11211'], binary=True)
mem.set('foo','this is a rather long string. this is a rather long string. this is a rather long string. this is a rather long string. this is a rather long string', 0, 10)
When above is run, we get same garbled value, which means it is not getting uncompressed. pylibmc is using zlib, so accordingly I have changed php's compression type to zlib also. What other setting needs to be done? Please help.
$memd = new Memcached();
For further reference here are the memcached's output after setting the string in python pylibmc
VALUE foo 8 40
And here's memcached's output for string stored using PHP's memcached client:
VALUE foo 48 44
As you can see there's something fishy in this. Compressed size in pylibmc is 40 bytes and the same data compressed using php-memcached is of 44 bytes. Also notice the flags as 8 when stored using pylibmc and 48 when stored using php-memcached !