mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
DEV: Make theme cache work like other caches (#20813)
This commit is contained in:
parent
7e23e6c1e8
commit
0728fa055b
@ -10,7 +10,7 @@ class Theme < ActiveRecord::Base
|
|||||||
|
|
||||||
attr_accessor :child_components
|
attr_accessor :child_components
|
||||||
|
|
||||||
@cache = DistributedCache.new("theme:compiler#{BASE_COMPILER_VERSION}")
|
@cache = DistributedCache.new("theme:compiler:#{BASE_COMPILER_VERSION}")
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :color_scheme
|
belongs_to :color_scheme
|
||||||
@ -331,13 +331,11 @@ class Theme < ActiveRecord::Base
|
|||||||
|
|
||||||
theme_ids = !skip_transformation ? transform_ids(theme_id) : [theme_id]
|
theme_ids = !skip_transformation ? transform_ids(theme_id) : [theme_id]
|
||||||
cache_key = "#{theme_ids.join(",")}:#{target}:#{field}:#{Theme.compiler_version}"
|
cache_key = "#{theme_ids.join(",")}:#{target}:#{field}:#{Theme.compiler_version}"
|
||||||
lookup = @cache[cache_key]
|
|
||||||
return lookup.html_safe if lookup
|
|
||||||
|
|
||||||
target = target.to_sym
|
get_set_cache(cache_key) do
|
||||||
val = resolve_baked_field(theme_ids, target, field)
|
target = target.to_sym
|
||||||
|
resolve_baked_field(theme_ids, target, field) || ""
|
||||||
get_set_cache(cache_key) { val || "" }.html_safe
|
end.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.lookup_modifier(theme_ids, modifier_name)
|
def self.lookup_modifier(theme_ids, modifier_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user