A cache store implementation which stores everything on the filesystem.
Methods
Attributes
[R] | cache_path |
Public Class methods
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 7 7: def initialize(cache_path) 8: @cache_path = cache_path 9: end
Public Instance methods
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 25 25: def delete(name, options = nil) 26: super 27: File.delete(real_file_path(name)) 28: rescue SystemCallError => e 29: # If there's no cache, then there's nothing to complain about 30: end
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 32 32: def delete_matched(matcher, options = nil) 33: super 34: search_dir(@cache_path) do |f| 35: if f =~ matcher 36: begin 37: File.delete(f) 38: rescue SystemCallError => e 39: # If there's no cache, then there's nothing to complain about 40: end 41: end 42: end 43: end
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 45 45: def exist?(name, options = nil) 46: super 47: File.exist?(real_file_path(name)) 48: end
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 11 11: def read(name, options = nil) 12: super 13: File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil 14: end
[ show source ]
# File activesupport/lib/active_support/cache/file_store.rb, line 16 16: def write(name, value, options = nil) 17: super 18: ensure_cache_path(File.dirname(real_file_path(name))) 19: File.atomic_write(real_file_path(name), cache_path) { |f| Marshal.dump(value, f) } 20: value 21: rescue => e 22: logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger 23: end