Recently, companies have to capture, Java is not efficient, and then C is selected to capture, to improve transmission efficiency, they need to capture the gzip compressed data of webpages,
Therefore, you must use Java to read the gzip compressed string of the webpage stored in memcached by C, decompress the webpage text,
After several days of tossing and turning over the official documentation, I read the source code and finally solved the reading problem.
1. memcached default replica set is a UTF-8, so if the ordinary text is saved, it is no problem to take it out.
But now the stored is compressed text string, so with the default UTF-8 to take out there will be a problem, it is necessary to change its default limit set
Memcachedclient MCC = new memcachedclient ("server" + IND );
MCC. setdefaultencoding ("ISO-8859-1"); // change the default replica set (it seems that only other tests with the ISO-8859-1 do not work)
2. do not replace the default MCC. Get (key) method with MCC. Get (Key, null, true) When retrieving data. The difference lies in the third parameter.
It indicates that the string is returned directly when get is not decoded.
3. If you set the default delimiter set to ISO-8859-1, but take the common text needs to be converted as follows
S = new string (S. getbytes ("ISO-8859-1"), "UTF-8 ");
4. memcached uses urlencoder encoding for the key by default. If your key contains special characters, the key value will be changed. For example, @ will change to % 40.
// The value setting does not encode the key.
MCC. setsanitizekeys (false );
All of the above are processed by the COM. danga. memcached. memcachedclient client, and the system environment is win7.