【问题标题】:Connect to Google App Engine shared memcached from python3.7 runtime从 python3.7 运行时连接到 Google App Engine 共享 memcached
【发布时间】:2019-03-21 15:24:09
【问题描述】:
【问题讨论】:
标签:
python-3.x
google-app-engine
memcached
google-app-engine-python
【解决方案1】:
我进一步探索的感觉是,未来将不再支持 memcache API。相反,他们希望人们过渡到托管在云中的标准后端。例如,可以获得一个在云中开启了 30MB 存储的免费 Redis 实例。您可以像使用 memcached 一样将其用作缓存。我对此进行了测试,发现性能可以接受:
2018-10-16 21:03:09.733 PDT
Took 1.3084499999999935 ms to get result OK (from set)
2018-10-16 21:03:09.735 PDT
Took 1.1954209999998966 ms to get result bar (from get)
2018-10-16 21:03:09.736 PDT
Took 1.0369539999999233 ms to get result null (from get)
这是使用 nodejs8 运行时,但我认为 Python 3.7 运行时不会有什么不同。如何设置的教程是here。
【讨论】:
-
Here你可以找到如何使用Redis Labs Cloud在Python 3.7中缓存应用数据。
【解决方案2】:
Memcache 是 documented,因为对于 Python3.7 运行时不可用:
Memcache 服务在 Python 3 中不可用。如果您需要访问托管缓存服务,您可以使用第三方 Memcache 服务,例如 Redis Labs Cloud。
更新:
文档已更新,现在建议使用 Google 的 Cloud MemoryStore [for Redis] 创建应用缓存。
要构建应用程序缓存,请创建一个 Cloud Memorystore 实例并使用无服务器 VPC 访问将其连接到您的应用程序。
请注意,与 Memcache 不同,Cloud Memorystore 是 not free。