aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Memcached.pm
diff options
context:
space:
mode:
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;