DEV: Make every DistributedCache lazily instantiated (#23147)

This commit is contained in:
Daniel Waterworth
2023-08-18 10:59:11 -05:00
committed by GitHub
parent 87ebbec9b2
commit 91f560a521
3 changed files with 15 additions and 9 deletions

View File

@@ -10,7 +10,9 @@ class Theme < ActiveRecord::Base
attr_accessor :child_components
@cache = DistributedCache.new("theme:compiler:#{BASE_COMPILER_VERSION}")
def self.cache
@cache ||= DistributedCache.new("theme:compiler:#{BASE_COMPILER_VERSION}")
end
belongs_to :user
belongs_to :color_scheme
@@ -202,7 +204,7 @@ class Theme < ActiveRecord::Base
end
def self.get_set_cache(key, &blk)
@cache.defer_get_set(key, &blk)
cache.defer_get_set(key, &blk)
end
def self.theme_ids
@@ -369,7 +371,7 @@ class Theme < ActiveRecord::Base
end
def self.clear_cache!
@cache.clear
cache.clear
end
def self.targets