Class: ActionController::Caching::Fragments::FileStore

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/caching.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(cache_path) ⇒ FileStore

Returns a new instance of FileStore.



337
338
339
# File 'lib/action_controller/caching.rb', line 337

def initialize(cache_path)
  @cache_path = cache_path
end

Instance Method Details

#delete(name, options) ⇒ Object

:nodoc:



352
353
354
# File 'lib/action_controller/caching.rb', line 352

def delete(name, options) #:nodoc:
  File.delete(real_file_path(name)) if File.exist?(real_file_path(name))
end

#delete_matched(re, options) ⇒ Object

:nodoc:



356
357
358
359
360
361
# File 'lib/action_controller/caching.rb', line 356

def delete_matched(re, options) #:nodoc:
  rootPath = real_file_path(options[:root_path])
  search_dir(@cache_path).each do |f|
    File.delete(f) if f.index(rootPath) == 0 and f =~ re and File.exist?(f)
  end
end

#read(name, options = {}) ⇒ Object

:nodoc:



348
349
350
# File 'lib/action_controller/caching.rb', line 348

def read(name, options = {}) #:nodoc:
  IO.read(real_file_path(name)) rescue nil
end

#write(name, value, options = {}) ⇒ Object

:nodoc:



341
342
343
344
345
346
# File 'lib/action_controller/caching.rb', line 341

def write(name, value, options = {}) #:nodoc:
  ensure_cache_path(File.dirname(real_file_path(name)))
  File.open(real_file_path(name), "w+") { |f| f.write(value) }
rescue => e
  Base.logger.info "Couldn't create cache directory: #{name} (#{e.message})" unless Base.logger.nil?
end