You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Does include IdentityCache automatically cache the model its included in? #390
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)?
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?
Activity
dylanahsmith commentedon Oct 17, 2019
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 IdentityCachedoes assume that it will be fetched, so it expires it to avoid stale reads if/when it is read from the cache. You can useinclude IdentityCache::WithoutPrimaryIndexinFooto avoid these cache invalidations for this primary key index forFoo.That sounds like it might be #211. Are you using
memcached_storeas recommended in the README?