Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Google App Engine shared memcached from python3.7 runtime

Google App Engine supports a Python 3.7 runtime on a beta basis, but I cannot figure out how to connect to the appengine memcache from that runtime. The documentation is strangely silent on the issue.

Here are the docs for python2.7: https://cloud.google.com/appengine/docs/standard/python/memcache/ However, note that python3.7 is grayed out. Does anyone know how to connect to this service in python3.7?

like image 771
James Aguilar Avatar asked Dec 14 '22 14:12

James Aguilar


2 Answers

Memcache is documented as being unavailable for the Python3.7 runtime:

The Memcache service is not available in Python 3. If you need access to a hosted caching service, you can use a third party memcache service like Redis Labs Cloud.

Update:

The documentation has been updated, and now recommends using Google's Cloud MemoryStore [for Redis] to create an application cache.

To build an application cache, create a Cloud Memorystore instance and connect it to your app using Serverless VPC Access.

Note that unlike Memcache, Cloud Memorystore is not free.

like image 134
snakecharmerb Avatar answered Jan 21 '23 12:01

snakecharmerb


My sense from exploring further is that the memcache API is not going to be supported going forward. Instead, they're expecting people to transition to standard backends hosted in the cloud. For example, it's possible to get a free Redis instance with 30MB of storage turned on in the cloud. You can use that as a cache the same way you would use memcached. I tested this and found performance acceptable:

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)

This was using the nodejs8 runtime, but I assume the Python 3.7 runtime would be no different. The tutorial on how to set this up is here.

like image 23
James Aguilar Avatar answered Jan 21 '23 13:01

James Aguilar