From 830044ee6f5fc7940ba06d7527c9fb09e046d6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 12 Dec 2013 14:09:04 -0200 Subject: Copy-edit the parent commit --- activesupport/lib/active_support/cache/file_store.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activesupport') 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) -- cgit v1.2.3