File tree Expand file tree Collapse file tree 8 files changed +353
-235
lines changed
appengine/flexible/memcache Expand file tree Collapse file tree 8 files changed +353
-235
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ $ composer install
1616** Prerequisites**
1717
1818- Install the [ Google Cloud SDK] ( https://developers.google.com/cloud/sdk/ ) .
19+ - Set up memcache using [ Redis Labs Memcache Cloud] [ redis labs memcache ] .
20+ - edit ` app.yaml ` and update the environment variables for your Memcache
21+ instance.
1922
2023** Deploy with gcloud**
2124
@@ -33,4 +36,6 @@ $ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a
3336$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a -T hello.txt
3437$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a
3538hello
36- ```
39+ ```
40+
41+ [ redis labs memcache ] : https://cloud.google.com/appengine/docs/flexible/python/using-redislabs-memcache
Original file line number Diff line number Diff line change 2626$ app ->register (new TwigServiceProvider ());
2727$ app ['twig.path ' ] = [ __DIR__ ];
2828$ app ['memcached ' ] = function () {
29- $ addr = getenv ('MEMCACHE_PORT_11211_TCP_ADDR ' );
30- $ port = (int ) getenv ('MEMCACHE_PORT_11211_TCP_PORT ' );
29+ if (getenv ('USE_GAE_MEMCACHE ' )) {
30+ $ addr = getenv ('GAE_MEMCACHE_HOST ' ) ?: 'localhost ' ;
31+ $ port = getenv ('GAE_MEMCACHE_PORT ' ) ?: '11211 ' ;
32+ } else {
33+ $ server = getenv ('MEMCACHE_SERVER ' ) ?: 'localhost:11211 ' ;
34+ list ($ addr , $ port ) = explode (': ' , $ server );
35+ }
36+ $ username = getenv ('MEMCACHE_USERNAME ' );
37+ $ password = getenv ('MEMCACHE_PASSWORD ' );
3138 $ memcached = new Memcached ;
39+ if ($ username && $ password ) {
40+ $ memcached ->setOption (Memcached::OPT_BINARY_PROTOCOL , true );
41+ $ memcached ->setSaslAuthData ($ username , $ password );
42+ }
3243 if (!$ memcached ->addServer ($ addr , $ port )) {
3344 throw new Exception ("Failed to add server $ addr: $ port " );
3445 }
Original file line number Diff line number Diff line change @@ -2,4 +2,16 @@ runtime: php
22vm : true
33
44runtime_config :
5- document_root : web
5+ document_root : web
6+
7+ # [START env_variables]
8+ env_variables :
9+ # If you are using the App Engine Memcache service (currently in alpha),
10+ # uncomment this section and comment out the other Memcache variables.
11+ # USE_GAE_MEMCACHE: 1
12+ MEMCACHE_SERVER : your-memcache-server
13+ # If you are using a Memcached server with SASL authentiation enabled,
14+ # fill in these values with your username and password.
15+ MEMCACHE_USERNAME : " "
16+ MEMCACHE_PASSWORD : " "
17+ # [END env_variables]
Original file line number Diff line number Diff line change 66 "require-dev" : {
77 "gecko-packages/gecko-memcache-mock" : " ^2.0" ,
88 "google/cloud-tools" : " <=1.0" ,
9+ "paragonie/random_compat" : " ^2.0" ,
910 "guzzlehttp/guzzle" : " ^6.2" ,
1011 "monolog/monolog" : " ^1.19" ,
1112 "phpunit/phpunit" : " ~4"
You can’t perform that action at this time.
0 commit comments