4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/proc-cache.rb', line 4
def cache!(options={})
cache_path = tmp_cache_path
@logger = Logger.new(nil)
cache_path = options[:cache_path] if options[:cache_path]
expires = options[:expires] if options[:expires]
@logger = options[:logger] if options[:logger]
if File.exist? cache_path
@logger.info "cache file found: #{cache_path}"
return use_cache(cache_path, expires)
else
@logger.info "cache file not found, generating cache"
data = self.call
write_cache(cache_path, data)
return data
end
end
|