aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Memcached.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-06-17 15:56:04 +0100
committerM Somerville <matthew-github@dracos.co.uk>2020-11-11 10:29:20 +0000
commitd7aca19faade6fb8f4aa47213d0f38b14cb9854a (patch)
tree41d370d7e69ad994f7f1f6be8d63cf1e692f60df /perllib/Memcached.pm
parente8127dd563cb823a369104e505795e8897d2c1ad (diff)
[Bromley] Restrict waste lookups per day.
Diffstat (limited to 'perllib/Memcached.pm')
-rw-r--r--perllib/Memcached.pm11
1 files changed, 11 insertions, 0 deletions
diff --git a/perllib/Memcached.pm b/perllib/Memcached.pm
index d03897e5a..099440f82 100644
--- a/perllib/Memcached.pm
+++ b/perllib/Memcached.pm
@@ -33,4 +33,15 @@ sub delete {
instance->delete(@_);
}
+sub increment {
+ my $key = shift;
+ my $timeout = shift;
+ my $count = instance->incr($key);
+ if (!defined $count) {
+ instance->add($key, 0, $timeout);
+ $count = instance->incr($key);
+ };
+ return $count;
+}
+
1;