Shopify / Shopify/identity_cache
How can I get a key for a fetch_by_some_attribute([a, b]) if the result is nil?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 174
- Avg merge
- 13m
- Merged PRs (30d)
- 3
Description
So I'm running into stale data issues as per the warning in the readme.
I would like to just invalidate / not even store the result if a fetch_by_some_attribute returns nil.
Failing that, I would like to invalidate the cache by doing IdentityCache.cache.clear(some_key).
But how do I get the key from
Model.fetch_by_some_attribute(['green', 'red'])
if it returns nil?
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 by reading the README warning about stale data, then trace Model.fetch_by_some_attribute(['green', 'red']) and the IdentityCache.cache.clear(some_key) path. Determine whether nil results should be invalidated or whether callers need a way to obtain the cache key, and define tests that demonstrate the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100