From e4f5114aaf9cea72df735443062c26803fee0ed6 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 bd0efb71885..2d1b70661bd 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 efa625eb5bf..72f04f00a72 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 d101cc17893..47aa1447775 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