我使用泡沫https://fedorahosted.org/suds/来使用SOAP获取数据。我想缓存结果(使用memcached)不要从我要提取数据的地方重载服务器。问题是在获取缓存的数据时。获取它工作正常,但随后的Django试图将数据(force_unicode)解码和它失败,出现以下:缓存泡沫对象。 Unicode问题
The string that could not be encoded/decoded was: armv�rmare t
这是我使用缓存的结果(其中结果=泡对象)。使用cPickle(并尝试过腌制以防万一,但没有成功,不出意外)。
泡沫响应是unicode。
#Cache the result
cache.set(hashstring, pickle.dumps(result), 120)
#Return the cached data
result = cache.get(hashstring)
if result:
return pickle.loads(result, encoding='utf-8')
我不确定memcached支持它,但我也尝试用pickle存储到一个文件,我也遇到了问题。 – xintron 2010-03-06 10:31:59