Parent

Class/Module Index [+]

Quicksearch

ActiveSupport::Cache::FileStore

A cache store implementation which stores everything on the filesystem.

Attributes

cache_path[R]

Public Class Methods

new(cache_path) click to toggle source
# File lib/active_support/cache/file_store.rb, line 7
def initialize(cache_path)
  @cache_path = cache_path
end

Public Instance Methods

delete(name, options = nil) click to toggle source
# File lib/active_support/cache/file_store.rb, line 25
def delete(name, options = nil)
  super
  File.delete(real_file_path(name))
rescue SystemCallError => e
  # If there's no cache, then there's nothing to complain about
end
delete_matched(matcher, options = nil) click to toggle source
# File lib/active_support/cache/file_store.rb, line 32
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
      end
    end
  end
end
exist?(name, options = nil) click to toggle source
# File lib/active_support/cache/file_store.rb, line 45
def exist?(name, options = nil)
  super
  File.exist?(real_file_path(name))
end
read(name, options = nil) click to toggle source
# File lib/active_support/cache/file_store.rb, line 11
def read(name, options = nil)
  super
  File.open(real_file_path(name), 'rb') { |f| Marshal.load(f) } rescue nil
end
write(name, value, options = nil) click to toggle source
# File lib/active_support/cache/file_store.rb, line 16
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
rescue => e
  logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.