From 7e23e6c1e810b21566e9c5a4ae00819b76decde7 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Fri, 24 Mar 2023 12:36:55 -0500 Subject: [PATCH] DEV: Make banner cache work like other caches (#20811) --- app/controllers/application_controller.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 80b6a77e7c2..42099571bef 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -686,16 +686,15 @@ class ApplicationController < ActionController::Base end def banner_json - json = ApplicationController.banner_json_cache["json"] return "{}" if !current_user && SiteSetting.login_required? - unless json - topic = Topic.where(archetype: Archetype.banner).first - banner = topic.present? ? topic.banner : {} - ApplicationController.banner_json_cache["json"] = json = MultiJson.dump(banner) - end - - json + ApplicationController + .banner_json_cache + .defer_get_set("json") do + topic = Topic.where(archetype: Archetype.banner).first + banner = topic.present? ? topic.banner : {} + MultiJson.dump(banner) + end end def custom_emoji