From 11b3ee4f4c1ede03f31dff4048283480ee22dd5f Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 28 Oct 2018 06:42:34 +0100 Subject: Reset status cache when status_stat or media_attachment updates (#9119) * Reset status cache when status_stat or media_attachment updates Fix #8711 Media attachments are generally immutable, but admins can update the sensitive flag, and this would ensure the change is visible instantly. Same for updates to status stats. That is a regression from #8185, because even the correct updated_at fetched from a join doesn't seem to invalidate the cache. * Remove join from Status#cache_ids since it has no effect --- app/models/status_stat.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/models/status_stat.rb') diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb index 9d358776b..024c467e7 100644 --- a/app/models/status_stat.rb +++ b/app/models/status_stat.rb @@ -14,4 +14,12 @@ class StatusStat < ApplicationRecord belongs_to :status, inverse_of: :status_stat + + after_commit :reset_parent_cache + + private + + def reset_parent_cache + Rails.cache.delete("statuses/#{status_id}") + end end -- cgit