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
Context:
I have EntityA which hasOne EntityB that can be NULL.
My problem:
I'm trying to cache the association to avoid querying it everytime i call $entityA->entity_b, so on the EntityA's Entity file i have:
public function _getEntityB()
{
if ($this->entityB === 'UNSET')
$this->entityB = TableRegistry::get('EntityB')->findByKeyId($this->id)->first();
return $this->entityB;
}
but because entityB is NULL, _parentGet returns null and tries to lazyload it everytime.
Is there any solution besides changing $entityA->entity_b for something else ?
The text was updated successfully, but these errors were encountered:
Sorry for the super late response, I'm not sure how I missed the notification!
If you're using the lazy load plugin you shouldn't need to cache anything that's lazily loaded. It won't try to reload it if the property exists. So, if it's null, it will lazy load, then on following calls it will just return what was loaded on that first request. Let me know if that makes sense.
If you're finding it's repeatedly loading for every call please provide me with a test case as I'd very much like to fix that bug.
Context:
I have EntityA which hasOne EntityB that can be NULL.
My problem:
I'm trying to cache the association to avoid querying it everytime i call
$entityA->entity_b
, so on the EntityA's Entity file i have:but because entityB is NULL,
_parentGet
returns null and tries to lazyload it everytime.Is there any solution besides changing
$entityA->entity_b
for something else ?The text was updated successfully, but these errors were encountered: