playground: specify memcache address via an env variable
This prevents those running on their own services from getting a
connection error if there is not a memcached server with that
exact name on the network.
Change-Id: Ib89630c33dc647979827d57fb40571cb21f462ab
Reviewed-on: https://go-review.googlesource.com/86249
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/app.yaml b/app.yaml
index 14b8cfd..77cba63 100644
--- a/app.yaml
+++ b/app.yaml
@@ -8,4 +8,7 @@
health_check:
check_interval_sec: 20
- restart_threshold: 10
\ No newline at end of file
+ restart_threshold: 10
+
+env_variables:
+ MEMCACHED_ADDR: 'memcached:11211'
diff --git a/main.go b/main.go
index ee5bdb6..94a96bf 100644
--- a/main.go
+++ b/main.go
@@ -28,8 +28,11 @@
}
s.db = cloudDatastore{client: c}
}
- if os.Getenv("GAE_INSTANCE") != "" {
- s.cache = newGobCache("memcached:11211")
+ if caddr := os.Getenv("MEMCACHED_ADDR"); caddr != "" {
+ s.cache = newGobCache(caddr)
+ log.Printf("App (project ID: %q) is caching results", pid)
+ } else {
+ log.Printf("App (project ID: %q) is NOT caching results", pid)
}
s.log = log
return nil