lib/rails-settings/base.rb in rails-settings-cached-2.3.5 vs lib/rails-settings/base.rb in rails-settings-cached-2.4.0

- old
+ new

@@ -1,9 +1,7 @@ # frozen_string_literal: true -require "request_store" - module RailsSettings class Base < ActiveRecord::Base class SettingNotFound < RuntimeError; end SEPARATOR_REGEXP = /[\n,;]+/.freeze @@ -23,11 +21,11 @@ self.class.clear_cache end class << self def clear_cache - RequestStore.store[:rails_settings_all_settings] = nil + RequestStore.reset Rails.cache.delete(cache_key) end def field(key, **opts) _define_field(key, default: opts[:default], type: opts[:type], readonly: opts[:readonly], separator: opts[:separator]) @@ -160,10 +158,10 @@ def rails_initialized? Rails.application&.initialized? end def _all_settings - RequestStore.store[:rails_settings_all_settings] ||= begin + RequestStore.settings ||= begin Rails.cache.fetch(cache_key, expires_in: 1.week) do vars = unscoped.select("var, value") result = {} vars.each { |record| result[record.var] = record.value } result.with_indifferent_access