From 6287566eb8a979236cf0fc9f6c89574c22fc9ab1 Mon Sep 17 00:00:00 2001 From: xxq250 Date: Mon, 18 Nov 2024 17:24:57 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20EduSetting=E5=80=BC1=E4=BD=8D=E6=97=B6?= =?UTF-8?q?=E5=A4=AA=E7=9F=AD=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/edu_setting.rb | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/app/models/edu_setting.rb b/app/models/edu_setting.rb index f4a89c09b..64cec6e92 100644 --- a/app/models/edu_setting.rb +++ b/app/models/edu_setting.rb @@ -1,19 +1,19 @@ -# == Schema Information -# -# Table name: edu_settings -# -# id :integer not null, primary key -# name :string(255) -# value :string(255) -# created_at :datetime not null -# updated_at :datetime not null -# description :string(255) -# -# Indexes -# -# index_edu_settings_on_name (name) UNIQUE -# - +# == Schema Information +# +# Table name: edu_settings +# +# id :integer not null, primary key +# name :string(255) +# value :string(255) +# created_at :datetime not null +# updated_at :datetime not null +# description :string(255) +# +# Indexes +# +# index_edu_settings_on_name (name) UNIQUE +# + class EduSetting < ApplicationRecord after_commit :expire_value_cache @@ -25,7 +25,11 @@ class EduSetting < ApplicationRecord end def self.get(key) - Rails.cache.fetch(value_cache_key(key), expires_in: 1.days) do + begin + Rails.cache.fetch(value_cache_key(key), expires_in: 1.days) do + find_by_name(key.to_s)&.value + end + rescue Exception => e find_by_name(key.to_s)&.value end end