Class: AppManager::Actions::ApiCacheHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/app_manager/api_cache_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ApiCacheHandler

Returns a new instance of ApiCacheHandler.



4
5
6
7
# File 'lib/app_manager/api_cache_handler.rb', line 4

def initialize(options)
  @options       = options
  @expires_in    = @options[:expires_in]
end

Instance Method Details

#around(controller) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/app_manager/api_cache_handler.rb', line 10

def around(controller)
  init(controller)
  if should_response_cache?
    log_info
    render_cached_response
  else
    yield
    @response_cache.write_cache(controller.response) if @request.get?
  end
end