aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-04-16 12:16:45 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-04-16 12:16:47 +0100
commite03c3f4251e12043dcdb5497885e18e10bca8782 (patch)
tree146366c3b5007356ec45f9014be6f8f132466a25
parent461430079384a10fb9e433dcc7581af2a56c0fac (diff)
Always set memcached namespace.
The namespace was only being set in the web loop, so cron scripts were accessing different memcached keys. In particular, the state list would be shared between instances on the same host.
-rw-r--r--perllib/FixMyStreet/App.pm2
-rw-r--r--perllib/Memcached.pm14
2 files changed, 4 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index e23bc7622..590daa170 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -232,8 +232,6 @@ sub setup_request {
$c->model('DB::Problem')->set_restriction( $cobrand->site_key() );
- Memcached::set_namespace( FixMyStreet->config('FMS_DB_NAME') . ":" );
-
FixMyStreet::Map::set_map_class( $cobrand->map_type || $c->get_param('map_override') );
# All pages need this, either loading it or prefetching it
$c->stash->{map_js} = FixMyStreet::Map::map_javascript();
diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm
index 150594a01..63f22a645 100644
--- a/perllib/Memcached.pm
+++ b/perllib/Memcached.pm
@@ -1,21 +1,15 @@
-#
# Memcached.pm:
-# Trying out memcached on FixMyStreet
-#
-# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
-# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+# Tiny FixMyStreet memcached wrapper
package Memcached;
use strict;
use warnings;
use Cache::Memcached;
+use FixMyStreet;
-my ($memcache, $namespace);
-
-sub set_namespace {
- $namespace = shift;
-}
+my $memcache;
+my $namespace = FixMyStreet->config('FMS_DB_NAME') . ":";
sub instance {
return $memcache //= Cache::Memcached->new({