diff options
author | Lachlan Sylvester <lachlan.sylvester@hypothetical.com.au> | 2018-11-05 11:52:33 +1100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2019-04-16 22:54:15 +0200 |
commit | 4f2ac80d4cdb01c4d3c1765637bed76cc91c1e35 (patch) | |
tree | 130aef88d29cd5a18535ce5123b54364ea90a13c /activerecord/lib/active_record/integration.rb | |
parent | 758ba117a008b6ea2d3b92c53b6a7a8d7ccbca69 (diff) | |
download | rails-4f2ac80d4cdb01c4d3c1765637bed76cc91c1e35.tar.gz rails-4f2ac80d4cdb01c4d3c1765637bed76cc91c1e35.tar.bz2 rails-4f2ac80d4cdb01c4d3c1765637bed76cc91c1e35.zip |
Add collection cache versioning
Cache versioning enables the same cache key to be reused when the object
being cached changes by moving the volatile part of the cache key out of
the cache key and into a version that is embedded in the cache entry.
This is already occurring when the object being cached is an
`ActiveRecord::Base`, but when caching an `ActiveRecord::Relation`
we are currently still putting the volatile information (max updated at
and count) as part of the cache key.
This PR moves the volatile part of the relations `cache_key` into the
`cache_version` to support recycling cache keys for
`ActiveRecord::Relation`s.
Diffstat (limited to 'activerecord/lib/active_record/integration.rb')
-rw-r--r-- | activerecord/lib/active_record/integration.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/integration.rb b/activerecord/lib/active_record/integration.rb index b769541e95..c745bc1330 100644 --- a/activerecord/lib/active_record/integration.rb +++ b/activerecord/lib/active_record/integration.rb @@ -22,6 +22,14 @@ module ActiveRecord # # This is +true+, by default on Rails 5.2 and above. class_attribute :cache_versioning, instance_writer: false, default: false + + ## + # :singleton-method: + # Indicates whether to use a stable #cache_key method that is accompanied + # by a changing version in the #cache_version method on collections. + # + # This is +false+, by default until Rails 6.1. + class_attribute :collection_cache_versioning, instance_writer: false, default: false end # Returns a +String+, which Action Pack uses for constructing a URL to this |