google-app-engine - 在 App Engine Memcache 上实现 get_multi

标签 google-app-engine memcached python-memcached

我想知道是否有人可以帮忙。我正在使用这篇文章 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.

Multi Get Documentation

关于google-app-engine - 在 App Engine Memcache 上实现 get_multi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14400586/

相关文章:

google-app-engine - 谷歌应用/应用引擎 : https version of naked domain does not redirect

c# - 是否有用 C# 编写的 Memcached 等效项?

仅为PHP应用程序缓存图像

python - 如何安装 pylibmc(memcached 的 python 客户端)?

python 3 : Looking for alternatives to gevent and pylibmc/python-memcached

google-app-engine - GAE + Github = 无法让 Push-to-Deploy 实际工作

python - 如何让AppEngine在同一页面显示错误?

python - 在 memcache.get() 之前测试字符串是否是有效键

java - 如何在 Google 应用引擎中设置 Unicode?

python - 如果我想在内存缓存中存储一​​个 None 值怎么办?