Module: HalApi::Controller::Cache::ClassMethods

Included in:
HalApi::Controller::ClassMethods
Defined in:
lib/hal_api/controller/cache.rb

Instance Method Summary collapse

Instance Method Details

#cache_api_action(action, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hal_api/controller/cache.rb', line 18

def cache_api_action(action, options = {})
  options = cache_options.merge(options || {})
  cache_path_method = options.delete(:cache_path_method)
  cache_path_method ||= "#{action}_cache_path"
  unless options[:cache_path]
    options[:cache_path] = lambda do |c|
      c.send(:valid_params_for_action, action).merge _c: send(cache_path_method)
    end
  end
  caches_action(action, options)
end

#cache_optionsObject



30
31
32
# File 'lib/hal_api/controller/cache.rb', line 30

def cache_options
  { compress: true, expires_in: 1.hour, race_condition_ttl: 30 }
end