Class: ActionController::Caching::Fragments::UnthreadedFileStore

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

Overview

:nodoc:

Direct Known Subclasses

FileStore

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_path) ⇒ UnthreadedFileStore

Returns a new instance of UnthreadedFileStore.



471
472
473
# File 'lib/action_controller/caching.rb', line 471

def initialize(cache_path)
  @cache_path = cache_path
end

Instance Attribute Details

#cache_pathObject (readonly)

Returns the value of attribute cache_path.



469
470
471
# File 'lib/action_controller/caching.rb', line 469

def cache_path
  @cache_path
end

Instance Method Details

#delete(name, options) ⇒ Object

:nodoc:



486
487
488
489
490
# File 'lib/action_controller/caching.rb', line 486

def delete(name, options) #:nodoc:
  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) ⇒ Object

:nodoc:



492
493
494
495
496
497
498
499
500
501
502
# File 'lib/action_controller/caching.rb', line 492

def delete_matched(matcher, options) #:nodoc:
  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

#read(name, options = nil) ⇒ Object

:nodoc:



482
483
484
# File 'lib/action_controller/caching.rb', line 482

def read(name, options = nil) #:nodoc:
  File.open(real_file_path(name), 'rb') { |f| f.read } rescue nil
end

#write(name, value, options = nil) ⇒ Object

:nodoc:



475
476
477
478
479
480
# File 'lib/action_controller/caching.rb', line 475

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