1
0
Fork 0

Add some memory caching for now

This commit is contained in:
Andrew Tomaka 2015-11-03 13:15:48 -05:00
parent 44b4f7314d
commit 8c826b44ee
2 changed files with 7 additions and 4 deletions

View file

@ -1,10 +1,12 @@
class Api::V1::CardsController < Api::V1::BaseController class Api::V1::CardsController < Api::V1::BaseController
before_action :set_card, only: [:show] before_action :set_card, only: [:show]
def index def index
@cards = Card.includes(:character, :rarity, :type, :leader_skill, @cards = Rails.cache.fetch('api_all_cards', expires_in: 2.minutes) do
:passive_skill, :super_attack, :awaken_type, Card.includes(:character, :rarity, :type, :leader_skill,
:dokkan_card, :hp_stat, :atk_stat, :def_stat, :passive_skill, :super_attack, :awaken_type,
:links) :dokkan_card, :hp_stat, :atk_stat, :def_stat,
:links)
end
render json: @cards, root: false render json: @cards, root: false
end end

View file

@ -13,6 +13,7 @@ Rails.application.configure do
# Full error reports are disabled and caching is turned on. # Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false config.consider_all_requests_local = false
config.action_controller.perform_caching = true 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 # Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this. # Add `rack-cache` to your Gemfile before enabling this.