Class: Hasta::S3FileCache
- Inherits:
-
Object
- Object
- Hasta::S3FileCache
- Defined in:
- lib/hasta/s3_file_cache.rb
Overview
Caches data in a flat namespace using Fog storage
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(fog_storage, bucket_name = 'cache') ⇒ S3FileCache
constructor
A new instance of S3FileCache.
- #put(key, data) ⇒ Object
Constructor Details
#initialize(fog_storage, bucket_name = 'cache') ⇒ S3FileCache
Returns a new instance of S3FileCache.
6 7 8 9 |
# File 'lib/hasta/s3_file_cache.rb', line 6 def initialize(fog_storage, bucket_name = 'cache') directories = fog_storage.directories @bucket = directories.get(bucket_name) || directories.create(:key => bucket_name) end |
Instance Method Details
#get(key) ⇒ Object
11 12 13 |
# File 'lib/hasta/s3_file_cache.rb', line 11 def get(key) bucket.files.get(key) end |
#put(key, data) ⇒ Object
15 16 17 |
# File 'lib/hasta/s3_file_cache.rb', line 15 def put(key, data) bucket.files.create(:key => key, :body => data) end |