Class: HousingMisc::CacheController

Inherits:
ApplicationController show all
Defined in:
app/controllers/housing_misc/cache_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#new_relic_custom_params

Methods inherited from ActionController::Base

#render

Instance Method Details

#showObject



3
4
5
6
7
8
9
# File 'app/controllers/housing_misc/cache_controller.rb', line 3

def show 
  render json: {data: {}, message: "cache key misisng", status: 404}, status: 404 if params['cache_key'].blank?
  data = Rails.cache.read(params['cache_key'])
  success_message, error_message = ["success", "not found"]
  data, message, status = data.present? ? [JSON.parse(data), success_message, 200] : [{}, error_message, 404]
  render json: {message: message, status: status, data: data }, status: status
end