Module: BlockCache::ControllerMethods
- Defined in:
- lib/block_cache.rb
Defined Under Namespace
Classes: NilResponseError
Instance Method Summary collapse
Instance Method Details
#cache_overwrite_by(key, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/block_cache.rb', line 33 def cache_overwrite_by(key, &block) raise ArgumentError, "needs a key and block" unless key && block return begin response_body = block.call() raise NilResponseError, "you returned a nil response" if response_body.nil? and not CACHE_NIL_RESPONSES BlockCache::Record.cache_by_key(key, response_body) rescue => exception logger.info "block cache error(#{exception.to_s}) returned, rendering from mongo." logger.debug "Backtrace:\n\n#{exception.backtrace}\n\n" HoptoadNotifier.notify_hoptoad(exception) if RAILS_ENV["production"] and HOPTOAD_SUPPORTED return BlockCache::Record.find_by_block_key(key).try(:block_response) end end |