From 4c9f14229f4d45b3cb4a9e042e0345796b9435e5 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 15 Sep 2023 19:52:28 +0200 Subject: [PATCH] Fix obsolete cache key in status cache invalidation logic (#26934) --- app/models/media_attachment.rb | 2 +- app/models/poll.rb | 2 +- app/models/status_stat.rb | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index bd0efb7188..2d1b70661b 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -407,6 +407,6 @@ class MediaAttachment < ApplicationRecord end def reset_parent_cache - Rails.cache.delete("statuses/#{status_id}") if status_id.present? + Rails.cache.delete("v3:statuses/#{status_id}") if status_id.present? end end diff --git a/app/models/poll.rb b/app/models/poll.rb index efa625eb5b..72f04f00a7 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -108,7 +108,7 @@ class Poll < ApplicationRecord def reset_parent_cache return if status_id.nil? - Rails.cache.delete("statuses/#{status_id}") + Rails.cache.delete("v3:statuses/#{status_id}") end def last_fetched_before_expiration? diff --git a/app/models/status_stat.rb b/app/models/status_stat.rb index d101cc1789..47aa144777 100644 --- a/app/models/status_stat.rb +++ b/app/models/status_stat.rb @@ -16,8 +16,6 @@ class StatusStat < ApplicationRecord belongs_to :status, inverse_of: :status_stat - after_commit :reset_parent_cache - def replies_count [attributes['replies_count'], 0].max end @@ -29,10 +27,4 @@ class StatusStat < ApplicationRecord def favourites_count [attributes['favourites_count'], 0].max end - - private - - def reset_parent_cache - Rails.cache.delete("statuses/#{status_id}") - end end