class Hasta::S3FileCache

Caches data in a flat namespace using Fog storage

Attributes

bucket[R]

Public Class Methods

new(fog_storage, bucket_name = 'cache') click to toggle source
# 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

Public Instance Methods

get(key) click to toggle source
# File lib/hasta/s3_file_cache.rb, line 11
def get(key)
  bucket.files.get(key)
end
put(key, data) click to toggle source
# File lib/hasta/s3_file_cache.rb, line 15
def put(key, data)
  bucket.files.create(:key => key, :body => data)
end