From 8c826b44ee3c5e7b0eb6405638b7d381cf4e5375 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 3 Nov 2015 13:15:48 -0500 Subject: [PATCH] Add some memory caching for now --- app/controllers/api/v1/cards_controller.rb | 10 ++++++---- config/environments/production.rb | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/cards_controller.rb b/app/controllers/api/v1/cards_controller.rb index 7b04385..bcbeac7 100644 --- a/app/controllers/api/v1/cards_controller.rb +++ b/app/controllers/api/v1/cards_controller.rb @@ -1,10 +1,12 @@ class Api::V1::CardsController < Api::V1::BaseController before_action :set_card, only: [:show] def index - @cards = Card.includes(:character, :rarity, :type, :leader_skill, - :passive_skill, :super_attack, :awaken_type, - :dokkan_card, :hp_stat, :atk_stat, :def_stat, - :links) + @cards = Rails.cache.fetch('api_all_cards', expires_in: 2.minutes) do + Card.includes(:character, :rarity, :type, :leader_skill, + :passive_skill, :super_attack, :awaken_type, + :dokkan_card, :hp_stat, :atk_stat, :def_stat, + :links) + end render json: @cards, root: false end diff --git a/config/environments/production.rb b/config/environments/production.rb index 1ac8424..912ea13 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,6 +13,7 @@ Rails.application.configure do # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true + config.cache_store = :memory_store # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this.