I keep getting these errors trying to read memcached variables stored by python3 scripts runnnig pylibmc.
PHP Warning: Memcached::get(): could not decompress value: unrecognised compression type in xxx
I’m saving some test data using this python3 script:
#!/usr/bin/env python3
import json
import pylibmc
mc = pylibmc.Client(["127.0.0.1"], binary=True,
behaviors={"cas": True, "tcp_nodelay": True,"ketama": True})
mc.set('testvar', json.dumps('{"greeting": "Hello", "title": "Mr"}'), 3600)
Using telnet to fetch the variable from memcached shows the data is NOT compressed, but saved in clear text:
ubuntu@server:~/bin$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get testvar
VALUE testvar 16 81
"{"greeting": "Hello", "title": "Mr"}"
END
^]
telnet> quit
Connection closed.
I have set the compression limit in the php-memcached settings to a huge number:
/etc/php/7.4/cli/conf.d/25-memcached.ini contains:
extension=memcached.so
; You need to install php-igbinary package to use igbinary serializer
; and php-msgpack to use msgpack serializer
memcached.serializer=php
memcached.compression_threshold=9999999999
The PHP script trying to read the data:
<?php
echo ini_get("memcached.compression_threshold") . "n";
$mc = new Memcached();
$mc->addServer('localhost', 11211);
$data = json_decode($mc->get('testvar'));
echo $data;
echo "n";
?>
and the output:
9999999999
PHP Warning: Memcached::get(): could not decompress value: unrecognised compression type in /home/ubuntu/bin/memcache_get.php on line 6
This is on a freshly installed Ubuntu 20 LTS system with python 3.8.10 and pylibmc Version: 1.6.1
Any hints anyone?