Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does include IdentityCache automatically cache the model its included in? #390

Open
johnernaut opened this issue Sep 20, 2019 · 1 comment

Comments

@johnernaut
Copy link

johnernaut commented Sep 20, 2019

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)?
@dylanahsmith
Copy link
Contributor

By including the module, is Foo and its attributes being stored into cache whenever its called?

It is a read-through cache, so it won't store Foo records in the cache if they aren't fetched through identity cache. However, include IdentityCache does assume that it will be fetched, so it expires it to avoid stale reads if/when it is read from the cache. You can use include IdentityCache::WithoutPrimaryIndex in Foo to avoid these cache invalidations for this primary key index for Foo.

Any ideas why a delete failed would be consistently called when updating one of Foo's attributes?

That sounds like it might be #211. Are you using memcached_store as recommended in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants