Class: ActiveSupport::Cache::FileStore

Inherits:
Store
  • Object
show all
Defined in:
lib/cache_fix.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_pathObject (readonly)

Returns the value of attribute cache_path.



8
9
10
# File 'lib/cache_fix.rb', line 8

def cache_path
  @cache_path
end

Instance Method Details

#read(name, options = nil) ⇒ Object



10
11
12
13
# File 'lib/cache_fix.rb', line 10

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) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/cache_fix.rb', line 15

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) }
rescue => e
  logger.error "Couldn't create cache directory: #{name} (#{e.message})" if logger
end