From 0728fa055b5b1ad5ae484173ebdb2413c44cc97c Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Fri, 24 Mar 2023 12:37:16 -0500 Subject: [PATCH] DEV: Make theme cache work like other caches (#20813) --- app/models/theme.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/models/theme.rb b/app/models/theme.rb index 902219e03b5..8c3464b53b5 100644 --- a/app/models/theme.rb +++ b/app/models/theme.rb @@ -10,7 +10,7 @@ class Theme < ActiveRecord::Base 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 :color_scheme @@ -331,13 +331,11 @@ class Theme < ActiveRecord::Base theme_ids = !skip_transformation ? transform_ids(theme_id) : [theme_id] cache_key = "#{theme_ids.join(",")}:#{target}:#{field}:#{Theme.compiler_version}" - lookup = @cache[cache_key] - return lookup.html_safe if lookup - target = target.to_sym - val = resolve_baked_field(theme_ids, target, field) - - get_set_cache(cache_key) { val || "" }.html_safe + get_set_cache(cache_key) do + target = target.to_sym + resolve_baked_field(theme_ids, target, field) || "" + end.html_safe end def self.lookup_modifier(theme_ids, modifier_name)