aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Memcached.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-04-04 17:07:57 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-04-06 17:42:23 +0100
commit149907dc7518957534ac207f677dc4caad1fe1ea (patch)
treeec9355129454b845ab13e1b0ff597895ca3a8642 /perllib/Memcached.pm
parentcff9dd65aed09d552f728a54719ed0587a538aee (diff)
Check recent reports for any hidden since cached.
Also stop caching lat/lon specific alert photo lists, and improve Memcached code.
Diffstat (limited to 'perllib/Memcached.pm')
-rw-r--r--perllib/Memcached.pm17
1 files changed, 6 insertions, 11 deletions
diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm
index b612dd5ac..150594a01 100644
--- a/perllib/Memcached.pm
+++ b/perllib/Memcached.pm
@@ -4,39 +4,34 @@
#
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: Memcached.pm,v 1.3 2008-10-10 15:57:28 matthew Exp $
-#
package Memcached;
use strict;
+use warnings;
use Cache::Memcached;
my ($memcache, $namespace);
sub set_namespace {
$namespace = shift;
- $namespace = 'fms' if $namespace eq 'fixmystreet';
}
-sub cache_connect {
- $memcache = new Cache::Memcached {
+sub instance {
+ return $memcache //= Cache::Memcached->new({
'servers' => [ '127.0.0.1:11211' ],
'namespace' => $namespace,
'debug' => 0,
'compress_threshold' => 10_000,
- };
+ });
}
sub get {
- cache_connect() unless $memcache;
- $memcache->get(@_);
+ instance->get(@_);
}
sub set {
- cache_connect() unless $memcache;
- $memcache->set(@_);
+ instance->set(@_);
}
1;