DEV: Make category topic_ids cache work like other caches (#20814)

This commit is contained in:
Daniel Waterworth
2023-03-27 09:23:29 -05:00
committed by GitHub
parent 3e80ab3143
commit d563b73202

View File

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