Class: S3Repo::Cache
Overview
Cache object, stores S3 objects on disk
Constant Summary collapse
- TMPDIRS =
[ENV['S3REPO_TMPDIR'], ENV['TMPDIR'], '/tmp/s3repo']
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Cache
constructor
A new instance of Cache.
- #serve(path, recheck = true) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Cache
Returns a new instance of Cache.
10 11 12 13 |
# File 'lib/s3repo/cache.rb', line 10 def initialize(params = {}) super [partialdir, cachedir].each { |x| FileUtils.mkdir_p x } end |
Instance Method Details
#serve(path, recheck = true) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/s3repo/cache.rb', line 15 def serve(path, recheck = true) epath = (path) prune(path, epath) if recheck download(path, epath) unless File.exist?(epath) File.open(epath) { |fh| fh.read } end |