aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Pearson <sam@sgp.me.uk>2018-09-20 12:08:16 +0100
committerSam Pearson <sam@sgp.me.uk>2018-09-20 14:19:16 +0100
commit785c6cebec327ebf1518c08f1447dbd12224b952 (patch)
tree0d5a33bd118907d99ce89a5dd5b6e9f6be413af2
parent1de47094d7a569c0055c0d23657140772c87d93d (diff)
Add configuration option for memcached host
Previously we assumed that any memcache instance would be running on the local loopback interface. This commit makes this configurable with a `MEMCACHED_HOST` option. If left unset, this will default to `127.0.0.1`.
-rw-r--r--CHANGELOG.md1
-rw-r--r--conf/general.yml-example4
-rw-r--r--perllib/Memcached.pm3
3 files changed, 7 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9cba54b8..f24b917e1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
- Cobrand hook for disabling updates on individual problems.
- Cobrand hook for disallowing title moderation. #2228
- Cobrand hook for per-questionnaire sending. #2231
+ - Add option for configuring memcache server.
* v2.4 (6th September 2018)
- Security
diff --git a/conf/general.yml-example b/conf/general.yml-example
index 9f1e2a01d..1f85b6fe7 100644
--- a/conf/general.yml-example
+++ b/conf/general.yml-example
@@ -197,6 +197,10 @@ SMTP_PASSWORD: ''
# this as is.
GAZE_URL: 'https://gaze.mysociety.org/gaze'
+# Memcached host
+# This can be safely left out and will default to '127.0.0.1' even if not present.
+MEMCACHED_HOST: '127.0.0.1'
+
# Should problem reports link to the council summary pages?
AREA_LINKS_FROM_PROBLEMS: '0'
diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm
index 63f22a645..05ceeb615 100644
--- a/perllib/Memcached.pm
+++ b/perllib/Memcached.pm
@@ -10,10 +10,11 @@ use FixMyStreet;
my $memcache;
my $namespace = FixMyStreet->config('FMS_DB_NAME') . ":";
+my $server = FixMyStreet->config('MEMCACHED_HOST') || '127.0.0.1';
sub instance {
return $memcache //= Cache::Memcached->new({
- 'servers' => [ '127.0.0.1:11211' ],
+ 'servers' => [ "${server}:11211" ],
'namespace' => $namespace,
'debug' => 0,
'compress_threshold' => 10_000,