aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/railtie.rb16
-rw-r--r--activesupport/lib/active_support/cache/file_store.rb6
-rw-r--r--activesupport/lib/active_support/cache/mem_cache_store.rb6
-rw-r--r--activesupport/lib/active_support/cache/memory_store.rb6
-rw-r--r--activesupport/lib/active_support/cache/null_store.rb6
-rw-r--r--activesupport/lib/active_support/cache/redis_cache_store.rb6
-rw-r--r--railties/CHANGELOG.md4
-rw-r--r--railties/test/application/configuration_test.rb2
8 files changed, 23 insertions, 29 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb
index fcee3de0b7..812fecbf32 100644
--- a/activerecord/lib/active_record/railtie.rb
+++ b/activerecord/lib/active_record/railtie.rb
@@ -92,17 +92,19 @@ module ActiveRecord
config.after_initialize do |app|
ActiveSupport.on_load(:active_record) do
if app.config.active_record.cache_versioning && Rails.cache
- unless Rails.cache.try(:supports_in_cache_versioning?)
+ unless Rails.cache.class.try(:supports_cache_versioning?)
raise <<-end_error
-You're using a cache store `#{Rails.cache.class}` that does not support
-"recyclable" cache keys, also known as "in cache versioning". To
-fix this issue either disable "recyclable" cache keys by setting:
+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).
- config.active_record.cache_versioning = false
+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:
-Or switching to a cache store that supports this functionality:
-https://guides.rubyonrails.org/caching_with_rails.html#cache-stores
+ config.active_record.cache_versioning = false
end_error
end
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb
index b17f0a4a4a..53a2b07536 100644
--- a/activesupport/lib/active_support/cache/file_store.rb
+++ b/activesupport/lib/active_support/cache/file_store.rb
@@ -26,10 +26,8 @@ module ActiveSupport
@cache_path = cache_path.to_s
end
- # Advertise that this cache store can be used
- # with "recyclable cache keys" otherwise known
- # as cache versioning.
- def supports_in_cache_versioning?
+ # Advertise cache versioning support.
+ def self.supports_cache_versioning?
true
end
diff --git a/activesupport/lib/active_support/cache/mem_cache_store.rb b/activesupport/lib/active_support/cache/mem_cache_store.rb
index f235f05d6c..174c784deb 100644
--- a/activesupport/lib/active_support/cache/mem_cache_store.rb
+++ b/activesupport/lib/active_support/cache/mem_cache_store.rb
@@ -47,10 +47,8 @@ module ActiveSupport
end
end
- # Advertise that this cache store can be used
- # with "recyclable cache keys" otherwise known
- # as cache versioning.
- def supports_in_cache_versioning?
+ # Advertise cache versioning support.
+ def self.supports_cache_versioning?
true
end
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb
index 32530fa2a9..106b616529 100644
--- a/activesupport/lib/active_support/cache/memory_store.rb
+++ b/activesupport/lib/active_support/cache/memory_store.rb
@@ -30,10 +30,8 @@ module ActiveSupport
@pruning = false
end
- # Advertise that this cache store can be used
- # with "recyclable cache keys" otherwise known
- # as cache versioning.
- def supports_in_cache_versioning?
+ # Advertise cache versioning support.
+ def self.supports_cache_versioning?
true
end
diff --git a/activesupport/lib/active_support/cache/null_store.rb b/activesupport/lib/active_support/cache/null_store.rb
index 405d485671..8452a28fd8 100644
--- a/activesupport/lib/active_support/cache/null_store.rb
+++ b/activesupport/lib/active_support/cache/null_store.rb
@@ -12,10 +12,8 @@ module ActiveSupport
class NullStore < Store
prepend Strategy::LocalCache
- # Advertise that this cache store can be used
- # with "recyclable cache keys" otherwise known
- # as cache versioning.
- def supports_in_cache_versioning?
+ # Advertise cache versioning support.
+ def self.supports_cache_versioning?
true
end
diff --git a/activesupport/lib/active_support/cache/redis_cache_store.rb b/activesupport/lib/active_support/cache/redis_cache_store.rb
index 4cee774908..9a55e49e27 100644
--- a/activesupport/lib/active_support/cache/redis_cache_store.rb
+++ b/activesupport/lib/active_support/cache/redis_cache_store.rb
@@ -66,10 +66,8 @@ module ActiveSupport
SCAN_BATCH_SIZE = 1000
private_constant :SCAN_BATCH_SIZE
- # Advertise that this cache store can be used
- # with "recyclable cache keys" otherwise known
- # as cache versioning.
- def supports_in_cache_versioning?
+ # Advertise cache versioning support.
+ def self.supports_cache_versioning?
true
end
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index da4beedecf..4342cf6968 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,7 @@
* Raise an error when "recyclable cache keys" are being used by a cache store
- that does not explicitly support it.
+ that does not explicitly support it. Custom cache keys that do support this feature
+ can bypass this error by implementing the `supports_cache_versioning?` method on their
+ class and returning a truthy value.
*Richard Schneeman*
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 386b4f76e6..8c10413525 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -133,7 +133,7 @@ module ApplicationTests
app "production"
end
- assert_match(/You're using a cache store/, error.message)
+ assert_match(/You're using a cache/, error.message)
end
test "a renders exception on pending migration" do