Revision 8137b14c
Added by Ondřej Ezr about 3 years ago
db/migrate/20190801143210_convert_dns_conflict_timeout_setting.rb | ||
---|---|---|
end
|
||
|
||
class ConvertDnsConflictTimeoutSetting < ActiveRecord::Migration[5.2]
|
||
def clean_cache
|
||
Rails.cache.delete(Setting.cache_key("dns_conflict_timeout"))
|
||
Rails.cache.delete(Setting.cache_key("dns_timeout"))
|
||
end
|
||
|
||
def up
|
||
Setting.without_auditing do
|
||
old_setting = FakeSetting.find_by_name("dns_conflict_timeout")
|
||
... | ... | |
new_setting.save!
|
||
end
|
||
old_setting.destroy!
|
||
clean_cache
|
||
end
|
||
end
|
||
|
||
def down
|
||
Setting.without_auditing do
|
||
FakeSetting.where("name = 'dns_timeout' or name = 'dns_conflict_timeout'").destroy_all
|
||
clean_cache
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #30862 - introduce SettingRegistry (#8002)
SettingRegistry keeps all the setting information as set of SettingPresenters in memory.
This registry should be the public API for accessing setting values and keeps all the information about settings.
That will allow dropping all information except `name` and `value` from database.
The public interface should be:
`Foreman.settings[<name>] => value` with syntactic suggar `Setting[<name>]` proxying to this method.
We load values from database per request and repopulate the values, what is quite fast. This allows us dropping the cache for setting.
Key implementation features:ready or not by `ready?` method.