어떻게 레일에 캐시를 액티브하는 액티브합니다 3.2.3어떻게 레일에서 캐시 3.2.3
stocks_controller.rb :
def index
@stocks = Rails.cache.read custom_cache_path(@res.uuid, Const::ACTIVE_STOCKS)
if @stocks.blank?
@stocks = Stock.only_active_stocks(params[:restaurant_id])
Rails.cache.write custom_cache_path(@res.uuid, Const::ACTIVE_STOCKS), @stocks
end
end
def show
@stocks = Rails.cache.read custom_cache_path(@res.uuid, Const::ACTIVE_STOCKS)
if @stocks.blank?
@stocks = Stock.only_active_stocks(params[:restaurant_id])
Rails.cache.write custom_cache_path(@res.uuid, Const::ACTIVE_STOCKS), @stocks
end
end
때 않는 show 액션 캐시 반환 전무에 요청?
하지'Rails.cache.fetch (ID, 발견 (ID))'에 관계없이 항상 캐시 히트의 DB에 충돌/그리워 할 것인가? –