File tree Expand file tree Collapse file tree
appengine/flexible/memcache Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,6 @@ Start your application:
2020
2121Deploy using ` gcloud ` :
2222
23- gcloud beta app deploy app.yaml
23+ gcloud app deploy
2424
2525You can now access the application at ` https://your-app-id.appspot.com ` .
Original file line number Diff line number Diff line change @@ -5,5 +5,14 @@ entrypoint: gunicorn -b :$PORT main:app
55runtime_config :
66 python_version : 3
77
8- beta_settings :
9- enable_app_engine_apis : true
8+ # [START env_variables]
9+ env_variables :
10+ # If you are using the App Engine Memcache service (currently in alpha),
11+ # uncomment this section and comment out the other Memcache variables.
12+ # USE_GAE_MEMCACHE: 1
13+ MEMCACHE_SERVER : your-memcache-server
14+ # If you are using a Memcached server with SASL authentiation enabled,
15+ # fill in these values with your username and password.
16+ MEMCACHE_USERNAME : your-memcache-username
17+ MEMCACHE_PASSWORD : your-memcache-password
18+ # [END env_variables]
Original file line number Diff line number Diff line change 1616import os
1717
1818from flask import Flask
19- from pymemcache .client .base import Client as MemcacheClient
20-
19+ import pylibmc
2120
2221app = Flask (__name__ )
2322
2423
2524# [START client]
26- memcache_addr = os .environ .get ('GAE_MEMCACHE_HOST' , 'localhost' )
27- memcache_port = os .environ .get ('GAE_MEMCACHE_PORT' , 11211 )
28- memcache_client = MemcacheClient ((memcache_addr , int (memcache_port )))
25+ # Environment variables are defined in app.yaml.
26+ if os .environ .get ('USE_GAE_MEMCACHE' ):
27+ MEMCACHE_SERVER = ':' .join (
28+ os .environ .get ('GAE_MEMCACHE_HOST' , 'localhost' ),
29+ os .environ .get ('GAE_MEMCACHE_PORT' , 11211 ))
30+ else :
31+ MEMCACHE_SERVER = os .environ .get ('MEMCACHE_SERVER' , 'localhost:11211' )
32+
33+ MEMCACHE_USERNAME = os .environ .get ('MEMCACHE_USERNAME' )
34+ MEMCACHE_PASSWORD = os .environ .get ('MEMCACHE_PASSWORD' )
35+
36+ memcache_client = pylibmc .Client (
37+ [MEMCACHE_SERVER ], binary = True ,
38+ username = MEMCACHE_USERNAME , password = MEMCACHE_PASSWORD )
2939# [END client]
3040
3141
Original file line number Diff line number Diff line change 11Flask == 0.11.1
22gunicorn == 19.6.0
3- pymemcache == 1.3.8
3+ pylibmc == 1.5.1
You can’t perform that action at this time.
0 commit comments