Class: ContentCaching::Adapter::Aws
- Inherits:
-
Object
- Object
- ContentCaching::Adapter::Aws
- Includes:
- RetryableBlock
- Defined in:
- lib/content_caching/adapters/aws.rb
Constant Summary collapse
- T_1_DAY =
86400.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #delete(document_path) ⇒ Object
-
#initialize(options) ⇒ Aws
constructor
A new instance of Aws.
- #store(document_path, content) ⇒ Object
- #url(document_path) ⇒ Object
Constructor Details
#initialize(options) ⇒ Aws
Returns a new instance of Aws.
12 13 14 |
# File 'lib/content_caching/adapters/aws.rb', line 12 def initialize @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/content_caching/adapters/aws.rb', line 10 def @options end |
Instance Method Details
#delete(document_path) ⇒ Object
28 29 30 31 32 |
# File 'lib/content_caching/adapters/aws.rb', line 28 def delete document_path retryable(3) do bucket.object(document_path).delete end end |
#store(document_path, content) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/content_caching/adapters/aws.rb', line 16 def store document_path, content retryable(3) do content.rewind if content.respond_to?(:rewind) bucket.put_object key: document_path, body: (content.respond_to?(:read) ? content.read : content) end end |
#url(document_path) ⇒ Object
24 25 26 |
# File 'lib/content_caching/adapters/aws.rb', line 24 def url document_path bucket.object(document_path).presigned_url :get, expires_in: T_1_DAY end |