From d563b7320264fbfe53249ff310175f595a730320 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Mon, 27 Mar 2023 09:23:29 -0500 Subject: [PATCH] DEV: Make category topic_ids cache work like other caches (#20814) --- app/models/category.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index 9c49f86f2ac..342b96ee7b5 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -204,11 +204,11 @@ class Category < ActiveRecord::Base @topic_id_cache = DistributedCache.new("category_topic_ids") def self.topic_ids - @topic_id_cache["ids"] || reset_topic_ids_cache + @topic_id_cache.defer_get_set("ids") { Set.new(Category.pluck(:topic_id).compact) } end def self.reset_topic_ids_cache - @topic_id_cache["ids"] = Set.new(Category.pluck(:topic_id).compact) + @topic_id_cache.clear end def reset_topic_ids_cache