diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-09-21 12:05:28 -0700 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-09-21 12:05:28 -0700 |
commit | 1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50 (patch) | |
tree | 36201d3efb5af8ae5ec1898fd6f3b8b366227819 /activesupport/lib/active_support/cache/file_store.rb | |
parent | e2d0b0ee61c5a8c2626abb5ac1029b48ec1965eb (diff) | |
parent | 4215e9ab936efca915ca998273d2fc0c46bb59b8 (diff) | |
download | rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.tar.gz rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.tar.bz2 rails-1bbb9b2db05730194edfd7d2cef9f5fcb9d79e50.zip |
Merge commit 'jose/orchestra'
Diffstat (limited to 'activesupport/lib/active_support/cache/file_store.rb')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 75eed5ed94..7521efe7c5 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -16,49 +16,53 @@ module ActiveSupport # - +:expires_in+ - the number of seconds that this value may stay in # the cache. def read(name, options = nil) - super + super do + file_name = real_file_path(name) + expires = expires_in(options) - file_name = real_file_path(name) - expires = expires_in(options) - - if File.exist?(file_name) && (expires <= 0 || Time.now - File.mtime(file_name) < expires) - File.open(file_name, 'rb') { |f| Marshal.load(f) } + if File.exist?(file_name) && (expires <= 0 || Time.now - File.mtime(file_name) < expires) + File.open(file_name, 'rb') { |f| Marshal.load(f) } + end end end # Writes a value to the cache. def write(name, value, options = nil) - super - ensure_cache_path(File.dirname(real_file_path(name))) - File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } - value + super do + ensure_cache_path(File.dirname(real_file_path(name))) + File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } + value + end rescue => e logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger end def delete(name, options = nil) - super - File.delete(real_file_path(name)) + super do + File.delete(real_file_path(name)) + end rescue SystemCallError => e # If there's no cache, then there's nothing to complain about end def delete_matched(matcher, options = nil) - super - search_dir(@cache_path) do |f| - if f =~ matcher - begin - File.delete(f) - rescue SystemCallError => e - # If there's no cache, then there's nothing to complain about + super do + search_dir(@cache_path) do |f| + if f =~ matcher + begin + File.delete(f) + rescue SystemCallError => e + # If there's no cache, then there's nothing to complain about + end end end end end def exist?(name, options = nil) - super - File.exist?(real_file_path(name)) + super do + File.exist?(real_file_path(name)) + end end private |