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.



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

def initialize(cache_path)
  @cache_path = cache_path
end

Instance Method Details

#delete(name, options) ⇒ Object

:nodoc:



372
373
374
375
376
# File 'lib/action_controller/caching.rb', line 372

def delete(name, options) #:nodoc:
  File.delete(real_file_path(name))
rescue SystemCallError => e
  Base.logger.info "Couldn't expire cache #{name} (#{e.message})" unless Base.logger.nil?
end

#delete_matched(matcher, options) ⇒ Object

:nodoc:



378
379
380
381
382
383
384
385
386
387
388
# File 'lib/action_controller/caching.rb', line 378

def delete_matched(matcher, options) #:nodoc:
  search_dir(@cache_path) do |f|
    if f =~ matcher
      begin 
        File.delete(f)
      rescue Object => e
        Base.logger.info "Couldn't expire cache: #{f} (#{e.message})" unless Base.logger.nil?
      end
    end
  end
end

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

:nodoc:



368
369
370
# File 'lib/action_controller/caching.rb', line 368

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

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

:nodoc:



361
362
363
364
365
366
# File 'lib/action_controller/caching.rb', line 361

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