has_many :through relations that return the same number of records and one common record with the max updated_at will generate the same cache_key. For example:
class Access < ActiveRecord::Base; end
class Person < ActiveRecord::Base; end
class Bucket < ActiveRecord::Base
has_many :people, through: :accesses
end
>> bucket.people.map(&:name)
=> ["Victor Cooper", "Jared Davis"]
>> bucket.people.cache_key
=> "people/query-2343a4c885c823c01ef9c2eb358b73eb-2-20161229150259317823"
Above, Victor Cooper has the max updated_at (20161229150259317823). If we remove Jared Davis and add a new person who's updated_at is less than Victor's, we'll get the same cache_key:
>> bucket.reload.people.map(&:name)
=> ["Victor Cooper", "Amy Rivera"]
>> bucket.people.cache_key
=> "people/query-2343a4c885c823c01ef9c2eb358b73eb-2-20161229150259317823"
This was introduced in #20884. /cc @afcapel @sgrif
has_many :throughrelations that return the same number of records and one common record with the maxupdated_atwill generate the samecache_key. For example:Above, Victor Cooper has the max
updated_at(20161229150259317823). If we remove Jared Davis and add a new person who'supdated_atis less than Victor's, we'll get the samecache_key:This was introduced in #20884. /cc @afcapel @sgrif