cmemcached和python memcache的兼容性问题

公司之前都是cmemcached作为beansdb的client,代码如下:

 

try:
    from cmemcached import Client
except:
    from memcache import Client

 最近发现通过

 

from memcache import Client

保存到beansdb的图片,cmemcached无法读取。 但cmemcached保存的图片,python memcache可以读取:

[admin@server2 beansdb]$ python test_mem.py 
Traceback (most recent call last):
  File "test_mem.py", line 7, in <module>
    print client.get(url)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/cmemcached.py", line 66, in get
    return restore(val, flag)
  File "/duitang/dist/sys/python/lib/python2.7/site-packages/cmemcached.py", line 33, in restore
    return cmemcached_imp.restore(val, flag)
  File "cmemcached_imp.pyx", line 320, in cmemcached_imp.restore
  File "cmemcached_imp.pyx", line 302, in cmemcached_imp._restore
ValueError: invalid literal for int() with base 10: "x\x9c\x9d\xbbeT[O\x14/\x1a\n-\xc5\x8b\x15\x87\x16w\x8a\x15'\xa5\xb4@\xa0@\x91\xe2\x10\xdc\xd2\xe0.I\x8b\xb6hq\x87R\xbcHp\x87\xe0RZ\xdc\xdd\xdd5@\x08\x8f\xff}\xef\xbe\xfb\xe5\xae\xf5d\x9f53\xe7\xac\xd9\xb3\xd7\xfe\x9d\xd92\xfb\xc3\xdcO\xdf/\x03\x9e)+\x80\x14"

 

 

之前以为是兼容性问题.通过比较保存到memcached server的值发现,python memcache默认会打开zlib压缩。草!草!草!草!草!草!草!草!

cmemcached:

 

VALUE test 0 329233^M
ÿØÿà^@^PJFIF^@^A^A^B^@'^@'^@^@ÿÛ^@C^@^C^B^B^B^B^B^C^B^B^B^C^C^C^C^D^F^D^D^D^D^D^H^F^F^E^F   ^H

    ^H
^L^O^L
^K^N^K      ^M^Q^M^N^O^P^P^Q^P
^L^R^S^R^P^S^O^P^P^PÿÛ^@C^A^C^C^C^D^C^D^H^D^D^H^P^K ^K^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^P^PÿÀ^@^Q^H  +^A¸^C^A"^@^B^Q^A^C^Q^AÿÄ^@^_^@^@^A^E^A^A^A^A^A^A^@^@^@^@^@^@^@^@^A^B^C^D^E^F^G^H
^KÿÄ^@µ^P^@^B^A^C^C^B^D^C^E^E^D^D^@^@^A}^A^B^C^@^D^Q^E^R!1A^F^SQa^G"q^T2<81><91>¡^H#B±Á^URÑð$3br<82>
^V^W^X^Y^Z%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz<83><84><85><86><87><88><89><8a><92><93><94><95><96><97><
 

 

python memcache:

 

VALUE test 8 314589^M
x<9c>¤»^GT^SÑ^['^Z@¤^[<90>¦ Dªt<94>ª<94>DA^DD¤HG@z^S^P¥^D   AéE@@<82><80><80>Ò{¤w<90>^^D<91>.¡<84>$^T^A<81>D4<8c>^PÂ㿯ì;ûvßÙ}ï<9b>óÍ<99>3sgîýÍ|íwÏ<9d>Ó^_§« öû÷ôï<81>hhhA×Î6Ðé"H^[DGû^_ùÏ<9e>îLÎ<9d>?÷^_a<^?<9e>þ<^S#33^S#^S^S3+<98><95><99>å^B^K^S^S^[^GÛ^E0;;^G;3ëEÎ<8b>ì<9c>gÇìÿy^HÍ^?î¤;Çxv#;^K^S^Kûÿ²<9c>~^Aq02IÓ´ÐÑ^H<83>h9hè8hNûA^P^P<88><86><9e>æ¿^Hèÿ^P^ZZºsôç^Y^X<99><98>YÎ^Z4²<83>hÏú¦=GGO^?îÜÙÕ°³ë s^\ô^W<85>nÜ9ÏiâÈ ìÏ¥ð:õ^S£<88>Vm^O·é$QTÑéy^D^S3^Oï¥Ë|bâ×$$¥<94><94>UToÞRÓ¾«sOWOÿþ#3s^KK+k^[g^WW7w^OO¯^W^A<81>AÁð<90><97><91>QÑ1±qñ iéï2P<99>ï³²^K
<8b><8a>KJËÊ+êê^[^Z<9b><9a>[ZÛzûú^G^F<87><86>GF§¦gfçæ^?,`pxÂÚúÆæÏ­mÒï<83>?^?É<87>À¿£ÿà¢^AÑÑü<9f>òßÅÅq<86><8b>öÜÙ+eø^O.^ZÚàÿ4à8G/tãüÅ;&^L<8e>þ<9c>Â
¯^Y¹´R?Õö0<89>(<9a>^R¹<9d><9e>O2ó<88>*áÄHÿ<81>ö_<90>ýÏ^A<8b>øÿ<84>ìÿ^Bö_qa@¬t4g^_<8f><8e>^C^D^C<9d><*H<90>^@ýÿÖô©^Ny<9b>¶<93>Ò^NÞÕå^WC^Pv¤"^B2¥<84>^EÛnóeü<99>Ã^^HôîO|جpóÃë*éL<95><9f>u^Z^I<8d>_<85>^[Úµ?3´M:pÃm   ¼»^C¤^WxÍê¡^^^Vt´½4`<8d>Û½3w
^Z<98>^?©¹òº^TÈö0Ð^Nt|r

 

你可能感兴趣的:(memcached)