Class: Heroku::Conn::Cache
- Inherits:
-
Object
- Object
- Heroku::Conn::Cache
- Defined in:
- lib/heroku/conn/cache.rb
Defined Under Namespace
Classes: CachePair
Instance Method Summary collapse
- #fetch(r_type, etag) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
- #put(r_type, new_etag, json) ⇒ Object
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
6 7 8 9 |
# File 'lib/heroku/conn/cache.rb', line 6 def initialize() @response_cache = {} @etag_pointers = {} end |
Instance Method Details
#fetch(r_type, etag) ⇒ Object
26 27 28 29 |
# File 'lib/heroku/conn/cache.rb', line 26 def fetch(r_type, etag) Heroku::Properties.logger.info("[#{r_type} Cache] Fetching #{etag}") pair(r_type).etag[etag] end |
#put(r_type, new_etag, json) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/heroku/conn/cache.rb', line 11 def put(r_type, new_etag, json) pair = pair(r_type) key = key(json) old_etag, _ = pair.response[key] record = [new_etag, json] Heroku::Properties.logger.debug("[#{r_type} Cache] Caching #{key} #{new_etag}") Heroku::Properties.logger.debug("[#{r_type} Cache] Dissociating tag: #{old_etag}") pair.etag.delete(old_etag) pair.response[key] = record pair.etag[new_etag] = record record end |