Shopify / Shopify/identity_cache

Does `include IdentityCache` automatically cache the model its included in?

Open
#390 1 comment 0 reactions 0 assignees View on GitHub

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 Foo and its attributes being stored into cache whenever its called?
  • Any ideas why a delete failed would be consistently called when updating one of Foo's attributes?
  • Is there a way to prevent Foo from being cached (since I only want it's association to be cached)?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.