【发布时间】:2010-02-24 09:53:43
【问题描述】:
我正在使用 suds https://fedorahosted.org/suds/ 通过 SOAP 获取数据。我想缓存结果(使用 memcached),以免从我获取数据的服务器超载。问题是在获取缓存数据时。获取它工作正常,但随后 django 尝试解码数据(force_unicode)并失败并显示以下内容:
The string that could not be encoded/decoded was: armv�rmare t
这是我用来缓存结果的(其中 result = suds-object)。使用 cPickle(并尝试了 pickle 以防万一,但没有成功,不足为奇)。
suds 响应是 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')
【问题讨论】:
标签: django memcached pickle suds