mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
DEV: Make category topic_ids cache work like other caches (#20814)
This commit is contained in:

committed by
GitHub

parent
3e80ab3143
commit
d563b73202
@ -204,11 +204,11 @@ class Category < ActiveRecord::Base
|
|||||||
@topic_id_cache = DistributedCache.new("category_topic_ids")
|
@topic_id_cache = DistributedCache.new("category_topic_ids")
|
||||||
|
|
||||||
def self.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
|
end
|
||||||
|
|
||||||
def self.reset_topic_ids_cache
|
def self.reset_topic_ids_cache
|
||||||
@topic_id_cache["ids"] = Set.new(Category.pluck(:topic_id).compact)
|
@topic_id_cache.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_topic_ids_cache
|
def reset_topic_ids_cache
|
||||||
|
Reference in New Issue
Block a user