Class: ContentCaching::Adapter::Aws

Inherits:
Object
  • Object
show all
Defined in:
lib/content_caching/adapters/aws.rb

Constant Summary collapse

T_1_DAY =
86400.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Aws

Returns a new instance of Aws.



11
12
13
# File 'lib/content_caching/adapters/aws.rb', line 11

def initialize options
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/content_caching/adapters/aws.rb', line 9

def options
  @options
end

Instance Method Details

#delete(document_path) ⇒ Object



27
28
29
30
31
# File 'lib/content_caching/adapters/aws.rb', line 27

def delete document_path
  retry_3_times do
    s3_interface.delete self.options[:directory], document_path
  end
end

#store(document_path, content) ⇒ Object



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

def store document_path, content
  retry_3_times do
    content.rewind if content.respond_to?(:rewind)
    s3_interface.put self.options[:directory], document_path,
      (content.respond_to?(:read) ? content.read : content)
  end
end

#url(document_path) ⇒ Object



23
24
25
# File 'lib/content_caching/adapters/aws.rb', line 23

def url document_path
  s3_interface.get_link self.options[:directory], document_path, T_1_DAY
end