Shopify / Shopify/identity_cache
Does `include IdentityCache` automatically cache the model its included in?
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 174
- Avg merge
- 13m
- Merged PRs (30d)
- 3
Description
I have a model where I'm including IdentityCache, let's call it Foo. I don't necessarily want this model and all of its attributes cached, but I do want its relationship cached. I have a relationship defined like:
cache_belongs_to :thing
The cache works just fine for doing things like calling foo.fetch_thing, but I noticed that when an attribute for the Foo model is updated, I get logging that looks like:
[IdentityCache] expiring=Foo expiring_id=2342 ...
and then more output saying that a delete failed for IDC:7:blob:Foo:....
So I guess my questions are:
- By including the module, is
Fooand its attributes being stored into cache whenever its called? - Any ideas why a
delete failedwould be consistently called when updating one ofFoo's attributes? - Is there a way to prevent
Foofrom being cached (since I only want it's association to be cached)?
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 tracing the IdentityCache module inclusion and the cache_belongs_to relationship behavior described in the issue. Reproduce an attribute update on Foo and inspect the resulting expiration and delete-failed logs; the work is done when the caching behavior, deletion failure, and possibility of association-only caching are explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100