Class: Alephant::Cache
- Inherits:
-
Object
- Object
- Alephant::Cache
- Defined in:
- lib/alephant/models/cache.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #get(id) ⇒ Object
-
#initialize(id, path) ⇒ Cache
constructor
A new instance of Cache.
- #put(id, data) ⇒ Object
Constructor Details
#initialize(id, path) ⇒ Cache
Returns a new instance of Cache.
7 8 9 10 11 12 13 14 15 |
# File 'lib/alephant/models/cache.rb', line 7 def initialize(id, path) @logger = ::Alephant.logger @id = id @path = path s3 = AWS::S3.new @bucket = s3.buckets[id] @logger.info("Cache.initialize: end with id #{id} and path #{path}") end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
5 6 7 |
# File 'lib/alephant/models/cache.rb', line 5 def bucket @bucket end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/alephant/models/cache.rb', line 5 def id @id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/alephant/models/cache.rb', line 5 def path @path end |
Instance Method Details
#get(id) ⇒ Object
22 23 24 25 |
# File 'lib/alephant/models/cache.rb', line 22 def get(id) @logger.info("Cache.get: #{@path}/#{id}") @bucket.objects["#{@path}/#{id}"].read end |
#put(id, data) ⇒ Object
17 18 19 20 |
# File 'lib/alephant/models/cache.rb', line 17 def put(id, data) @bucket.objects["#{@path}/#{id}"].write(data) @logger.info("Cache.put: #{@path}/#{id}") end |