aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-12 14:09:04 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-12-12 14:09:04 -0200
commit830044ee6f5fc7940ba06d7527c9fb09e046d6e3 (patch)
tree25a7d7fd9bf142004f8ec0c5ada6e1d27c4f22ee /activesupport
parent415d1e10e395b91c83bdb7d692ffd93c5ca73814 (diff)
downloadrails-830044ee6f5fc7940ba06d7527c9fb09e046d6e3.tar.gz
rails-830044ee6f5fc7940ba06d7527c9fb09e046d6e3.tar.bz2
rails-830044ee6f5fc7940ba06d7527c9fb09e046d6e3.zip
Copy-edit the parent commit
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index d8d910acb6..8ed60aebac 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -22,8 +22,8 @@ module ActiveSupport
extend Strategy::LocalCache
end
- # Deletes all items from the cache. In this case it deletes all the entries in the specified
- # file store directory except for .gitkeep. Be careful which directory is specified in your
+ # Deletes all items from the cache. In this case it deletes all the entries in the specified
+ # file store directory except for .gitkeep. Be careful which directory is specified in your
# config file when using +FileStore+ because everything in that directory will be deleted.
def clear(options = nil)
root_dirs = Dir.entries(cache_path).reject {|f| (EXCLUDED_DIRS + [".gitkeep"]).include?(f)}
@@ -49,7 +49,7 @@ module ActiveSupport
# Decrements an already existing integer value that is stored in the cache.
# If the key is not found nothing is done.
def decrement(name, amount = 1, options = nil)
- modify_value(name, amount*-1, options)
+ modify_value(name, -amount, options)
end
def delete_matched(matcher, options = nil)
@@ -164,13 +164,15 @@ module ActiveSupport
end
end
end
-
- #This method performs an action(passed) already existing integer value that is stored in the cache
- # If the key is not found nothing is done
+
+ # Modifies the amount of an already existing integer value that is stored in the cache.
+ # If the key is not found nothing is done.
def modify_value(name, amount, options)
file_name = key_file_path(namespaced_key(name, options))
+
lock_file(file_name) do
options = merged_options(options)
+
if num = read(name, options)
num = num.to_i + amount
write(name, num, options)