1
0
Fork 0
forked from OpenNeo/impress

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!
This commit is contained in:
Matchu 2023-08-02 11:41:19 -07:00
parent beb5c14d42
commit 3ea22e6977
3 changed files with 1 additions and 29 deletions

View file

@ -37,9 +37,8 @@ class ItemsController < ApplicationController
end end
end end
elsif params.has_key?(:ids) && params[:ids].is_a?(Array) elsif params.has_key?(:ids) && params[:ids].is_a?(Array)
@items = Item.build_proxies(params[:ids]) @items = Item.find(params[:ids])
assign_closeted! assign_closeted!
@items.prepare_method(:as_json)
respond_to do |format| respond_to do |format|
format.json { render json: @items } format.json { render json: @items }
end end

View file

@ -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

View file

@ -2,11 +2,6 @@ class ItemObserver < ActionController::Caching::Sweeper
def after_create(item) def after_create(item)
Resque.enqueue(Item::CreateTask, item.id) Resque.enqueue(Item::CreateTask, item.id)
end 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) def after_destroy(item)
Resque.enqueue(Item::DestroyTask, item.id) Resque.enqueue(Item::DestroyTask, item.id)