Merge branch 'atomaka/feature/api-caching' into 'master'
Add some memory caching for now This is a very basic cache for the time being. I am not even sure if it is a performance gain. See merge request !17
This commit is contained in:
commit
480dbd1a64
2 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue