Class: ActiveSupport::Cache::FileStore
- Inherits:
-
Store
show all
- Defined in:
- lib/active_support/cache/file_store.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Store
#decrement, #fetch, #increment, #threadsafe!
Constructor Details
#initialize(cache_path) ⇒ FileStore
Returns a new instance of FileStore.
6
7
8
|
# File 'lib/active_support/cache/file_store.rb', line 6
def initialize(cache_path)
@cache_path = cache_path
end
|
Instance Attribute Details
#cache_path ⇒ Object
Returns the value of attribute cache_path.
4
5
6
|
# File 'lib/active_support/cache/file_store.rb', line 4
def cache_path
@cache_path
end
|
Instance Method Details
#delete(name, options = nil) ⇒ Object
23
24
25
26
27
28
|
# File 'lib/active_support/cache/file_store.rb', line 23
def delete(name, options = nil)
super
File.delete(real_file_path(name))
rescue SystemCallError => e
end
|
#delete_matched(matcher, options = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_support/cache/file_store.rb', line 30
def delete_matched(matcher, options = nil)
super
search_dir(@cache_path) do |f|
if f =~ matcher
begin
File.delete(f)
rescue SystemCallError => e
end
end
end
end
|
#exist?(name, options = nil) ⇒ Boolean
43
44
45
46
|
# File 'lib/active_support/cache/file_store.rb', line 43
def exist?(name, options = nil)
super
File.exist?(real_file_path(name))
end
|
#read(name, options = nil) ⇒ Object
10
11
12
13
|
# File 'lib/active_support/cache/file_store.rb', line 10
def read(name, options = nil)
super
File.open(real_file_path(name), 'rb') { |f| f.read } rescue nil
end
|
#write(name, value, options = nil) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/active_support/cache/file_store.rb', line 15
def write(name, value, options = nil)
super
ensure_cache_path(File.dirname(real_file_path(name)))
File.open(real_file_path(name), "wb+") { |f| f.write(value) }
rescue => e
RAILS_DEFAULT_LOGGER.error "Couldn't create cache directory: #{name} (#{e.message})" if RAILS_DEFAULT_LOGGER
end
|