Class: S3Repo::Cache

Inherits:
Base
  • Object
show all
Defined in:
lib/s3repo/cache.rb

Overview

Cache object, stores S3 objects on disk

Constant Summary collapse

TMPDIRS =
[
  ENV['TMPDIR'],
  Dir.tmpdir,
  '/tmp/s3repo'
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Cache

Returns a new instance of Cache.



15
16
17
18
# File 'lib/s3repo/cache.rb', line 15

def initialize(params = {})
  super
  [partialdir, cachedir].each { |x| FileUtils.mkdir_p x }
end

Instance Method Details

#download(key, refresh = true) ⇒ Object



20
21
22
23
24
# File 'lib/s3repo/cache.rb', line 20

def download(key, refresh = true)
  path = expand_path key
  get_object(key, path) if refresh || !cached?(path)
  path
end