Sha256: 887e48c2356db08ddf0d1ac3c78cce0b2c50a71714c43cc2ef10770fc54cd73f
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'aws' module ContentCaching module Adapter class Aws T_1_DAY = 86400.freeze attr_reader :options def initialize options @options = options end 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 def url document_path s3_interface.get_link self.options[:directory], document_path, T_1_DAY end def delete document_path retry_3_times do s3_interface.delete self.options[:directory], document_path end end private def s3_interface @s3_interface ||= ::Aws::S3Interface.new self.options[:aws_access_key_id], self.options[:aws_secret_access_key] end def retry_3_times tries = 0 begin yield rescue (tries += 1) <3 ? retry : raise end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
content_caching-0.1.1 | lib/content_caching/adapters/aws.rb |
content_caching-0.1.0 | lib/content_caching/adapters/aws.rb |