mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Use DistributedCache#defer_get_set instead of getting and setting (#25778)
We use defer_get_set everywhere else, so for consistency and reducing complexity, this is better.
This commit is contained in:
committed by
GitHub
parent
a4305cd69c
commit
0529d20db4
@@ -352,27 +352,26 @@ class Stylesheet::Manager
|
|||||||
target = COLOR_SCHEME_STYLESHEET.to_sym
|
target = COLOR_SCHEME_STYLESHEET.to_sym
|
||||||
current_hostname = Discourse.current_hostname
|
current_hostname = Discourse.current_hostname
|
||||||
cache_key = self.class.color_scheme_cache_key(color_scheme, theme_id)
|
cache_key = self.class.color_scheme_cache_key(color_scheme, theme_id)
|
||||||
stylesheets = cache[cache_key]
|
|
||||||
return stylesheets if stylesheets.present?
|
|
||||||
|
|
||||||
stylesheet = { color_scheme_id: color_scheme.id }
|
cache.defer_get_set(cache_key) do
|
||||||
|
stylesheet = { color_scheme_id: color_scheme.id }
|
||||||
|
|
||||||
theme = get_theme(theme_id)
|
theme = get_theme(theme_id)
|
||||||
|
|
||||||
builder =
|
builder =
|
||||||
Builder.new(
|
Builder.new(
|
||||||
target: target,
|
target: target,
|
||||||
theme: get_theme(theme_id),
|
theme: get_theme(theme_id),
|
||||||
color_scheme: color_scheme,
|
color_scheme: color_scheme,
|
||||||
manager: self,
|
manager: self,
|
||||||
)
|
)
|
||||||
|
|
||||||
builder.compile unless File.exist?(builder.stylesheet_fullpath)
|
builder.compile unless File.exist?(builder.stylesheet_fullpath)
|
||||||
|
|
||||||
href = builder.stylesheet_absolute_url
|
href = builder.stylesheet_absolute_url
|
||||||
stylesheet[:new_href] = href
|
stylesheet[:new_href] = href
|
||||||
cache.defer_set(cache_key, stylesheet.freeze)
|
stylesheet.freeze
|
||||||
stylesheet
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def color_scheme_stylesheet_preload_tag(color_scheme_id = nil, media = "all")
|
def color_scheme_stylesheet_preload_tag(color_scheme_id = nil, media = "all")
|
||||||
|
|||||||
Reference in New Issue
Block a user