From db74dd1e29170f2791cbe3d018b8ad521ba9331a Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Aug 2023 11:41:19 -0700 Subject: [PATCH] Remove as_json item caching Again I'm just not convinced of the perf on this, and it enables us to delete some whole infra over it, we can improve it another time if it's useful to! --- app/controllers/items_controller.rb | 3 +-- app/models/item/update_task.rb | 22 ---------------------- app/models/item_observer.rb | 5 ----- 3 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 app/models/item/update_task.rb diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index ee8edc94..2c49569d 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -37,9 +37,8 @@ class ItemsController < ApplicationController end end elsif params.has_key?(:ids) && params[:ids].is_a?(Array) - @items = Item.build_proxies(params[:ids]) + @items = Item.find(params[:ids]) assign_closeted! - @items.prepare_method(:as_json) respond_to do |format| format.json { render json: @items } end diff --git a/app/models/item/update_task.rb b/app/models/item/update_task.rb deleted file mode 100644 index ce986760..00000000 --- a/app/models/item/update_task.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Item - class UpdateTask - extend FragmentExpiration - - TIMEOUT_IN_SECONDS = 10 - - @queue = :item_update - - def self.perform(id) - Timeout::timeout(TIMEOUT_IN_SECONDS) do - item = Item.find(id) - expire_cache_for(item) - end - end - - private - - def self.expire_cache_for(item) - expire_key_in_all_locales("items/#{item.id}#as_json") - end - end -end \ No newline at end of file diff --git a/app/models/item_observer.rb b/app/models/item_observer.rb index c9e421db..a3ac5eb5 100644 --- a/app/models/item_observer.rb +++ b/app/models/item_observer.rb @@ -2,11 +2,6 @@ class ItemObserver < ActionController::Caching::Sweeper def after_create(item) Resque.enqueue(Item::CreateTask, item.id) end - - def after_update(item) - # CONSIDER: can pass item.changes.keys in to choose which caches to expire - Resque.enqueue(Item::UpdateTask, item.id) - end def after_destroy(item) Resque.enqueue(Item::DestroyTask, item.id)