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

Defined in:
lib/hal_api/controller/cache.rb

Instance Method Summary collapse

Instance Method Details

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



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/hal_api/controller/cache.rb', line 31

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



43
44
45
# File 'lib/hal_api/controller/cache.rb', line 43

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