diff options
author | Richard Schneeman <richard.schneeman+no-recruiters@gmail.com> | 2018-09-21 09:25:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 09:25:39 -0500 |
commit | b1223458979adc29117ffa1392526c6a166effed (patch) | |
tree | 85d7ed7dc3bd643cc17bafd49dd8e92fada80056 /activerecord/lib/active_record | |
parent | 40eb569377d46ccac82ac89b02fbeac77b1efe7f (diff) | |
parent | 3424bd83d699bb996aa27d85b970e484d37e3485 (diff) | |
download | rails-b1223458979adc29117ffa1392526c6a166effed.tar.gz rails-b1223458979adc29117ffa1392526c6a166effed.tar.bz2 rails-b1223458979adc29117ffa1392526c6a166effed.zip |
Merge pull request #33932 from schneems/schneems/recyclable-key-support-cache
[close #33907] Error when using "recyclable" cache keys with a store that does not support it
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index b213754641..812fecbf32 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -88,6 +88,31 @@ module ActiveRecord end end + initializer "Check for cache versioning support" do + config.after_initialize do |app| + ActiveSupport.on_load(:active_record) do + if app.config.active_record.cache_versioning && Rails.cache + unless Rails.cache.class.try(:supports_cache_versioning?) + raise <<-end_error + +You're using a cache store that doesn't support native cache versioning. +Your best option is to upgrade to a newer version of #{Rails.cache.class} +that supports cache versioning (#{Rails.cache.class}.supports_cache_versioning? #=> true). + +Next best, switch to a different cache store that does support cache versioning: +https://guides.rubyonrails.org/caching_with_rails.html#cache-stores. + +To keep using the current cache store, you can turn off cache versioning entirely: + + config.active_record.cache_versioning = false + +end_error + end + end + end + end + end + initializer "active_record.check_schema_cache_dump" do if config.active_record.delete(:use_schema_cache_dump) config.after_initialize do |app| |