Shopify / Shopify/identity_cache
Cache busting doesn't bubble up in some cases without eagerloading
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 174
- Avg merge
- 13m
- Merged PRs (30d)
- 3
Description
Given the following classes:
class A < AR::Base
has_many :bs, inverse: :a
cache_has_many(:bs, embed: true)
end
class B < AR::Base
belongs_to :a, inverse: :bs
has_one :c
cache_has_one(:c, embed: true)
end
class C < AR::Base
has_many :b, inverse: :c
end
when saving an instance of C, B gets removed from the cache, but not A. Thus, B#fetch_c returns the latest version but A#fetch_bs return a stale collection.
I could reproduce this scenario as a failing test: https://github.com/Shopify/identity_cache/compare/ancestor-invalidation-failing
Am I missing something or is this a bug?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing test in the ancestor-invalidation-failing comparison linked in the issue, using the A, B, and C association setup as the reproducer. Trace cache invalidation after saving C and compare B#fetch_c with A#fetch_bs. Done means saving C invalidates the cached collection returned by A#fetch_bs without requiring eager loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100