diff options
Diffstat (limited to 'activesupport/lib/active_support/cache.rb')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 64394afec4..463cba6cf0 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -87,8 +87,25 @@ module ActiveSupport def delete_matched(matcher, options = nil) log("delete matched", matcher.inspect, options) + end + + def increment(key, amount = 1) + log("incrementing", key, amount) + if num = read(key) + write(key, num + amount) + else + nil + end end + def decrement(key, amount = 1) + log("decrementing", key, amount) + if num = read(key) + write(key, num - amount) + else + nil + end + end private def log(operation, key, options) |