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
16
16
** Prerequisites**
17
17
18
18
- 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.
19
22
20
23
** Deploy with gcloud**
21
24
@@ -33,4 +36,6 @@ $ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a
33
36
$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a -T hello.txt
34
37
$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a
35
38
hello
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 26
26
$ app ->register (new TwigServiceProvider ());
27
27
$ app ['twig.path ' ] = [ __DIR__ ];
28
28
$ 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 ' );
31
38
$ memcached = new Memcached ;
39
+ if ($ username && $ password ) {
40
+ $ memcached ->setOption (Memcached::OPT_BINARY_PROTOCOL , true );
41
+ $ memcached ->setSaslAuthData ($ username , $ password );
42
+ }
32
43
if (!$ memcached ->addServer ($ addr , $ port )) {
33
44
throw new Exception ("Failed to add server $ addr: $ port " );
34
45
}
Original file line number Diff line number Diff line change @@ -2,4 +2,16 @@ runtime: php
2
2
vm : true
3
3
4
4
runtime_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 6
6
"require-dev" : {
7
7
"gecko-packages/gecko-memcache-mock" : " ^2.0" ,
8
8
"google/cloud-tools" : " <=1.0" ,
9
+ "paragonie/random_compat" : " ^2.0" ,
9
10
"guzzlehttp/guzzle" : " ^6.2" ,
10
11
"monolog/monolog" : " ^1.19" ,
11
12
"phpunit/phpunit" : " ~4"
You can’t perform that action at this time.
0 commit comments