我想知道是否有人可以帮忙。我正在使用这篇文章 here 中概述的 blobcache 模块
这工作正常,但我希望通过使用 get_multi() 来加快从内存缓存的检索速度 key 函数,但我当前的代码在使用 get_multi 时找不到键
我当前的 get def 看起来像这样
def get(key):
chunk_keys = memcache.get(key)
if chunk_keys is None:
return None
chunk_keys= ",".join(chunk_keys)
str(chunk_keys)
chunk = memcache.get_multi(chunk_keys)
if chunk is None:
return None
try:
return chunk
except Exception:
return None
我对文档的理解是,您只需要传递一串键到 get_multi 即可。
但是他目前没有返回任何内容。
有人可以指出我在这里做错了什么吗?
最佳答案
向其传递一个字符串列表(键),而不是其中包含逗号的单个字符串。
get_multi(keys, key_prefix='', namespace=None, for_cas=False)
keys = List of keys to look up. A Key can be a string or a tuple of (hash_value, string), where the hash_value, normally used for sharding onto a memcache instance, is instead ignored, as Google App Engine deals with the sharding transparently.
关于google-app-engine - 在 App Engine Memcache 上实现 get_multi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400586/