Use ActionCaching in OrderCyclesController (taxons and properties)

This commit is contained in:
Matt-Yorkley
2020-04-28 14:20:44 +02:00
parent 975afb3152
commit ea1ec1a1c6
2 changed files with 5 additions and 1 deletions

View File

@@ -1,10 +1,12 @@
module Api
class OrderCyclesController < Api::BaseController
include EnterprisesHelper
respond_to :json
include ApiActionCaching
skip_authorization_check
caches_action :taxons, :properties, expires_in: CacheService::FILTERS_EXPIRY
def products
products = ProductsRenderer.new(
distributor,

View File

@@ -1,6 +1,8 @@
# frozen_string_literal: true
class CacheService
FILTERS_EXPIRY = 30.seconds.freeze
def self.cache(cache_key, options = {})
Rails.cache.fetch cache_key.to_s, options do
yield