Closed maher1337 closed 1 year ago
Can you share some of the code? I want to see which implementation you have been using.
Just chiming in here as I believe I've had the same issue:
$attachment = Attachment::updateOrCreate(
['x_id' => $x->id, 'organisation_id' => $x->organisation_id],
['systems' => $systems, 'tags' => $tags, 'x_id' => $x->id, 'organisation_id' => $x->organisation_id]
);
I haven't gone deep to see if this is failing to invalidate cache but it looks like it is, and then I found this comment on upserts.
Yeah, upserts won't work. updateOrCreate requires a for loop with multiple UPDATE/INSERT transactions which could cause a heavy performance loss for say updating/inserting a 10^4 or more queries.
Upsert is a Query Builder instance and is not a Eloquent Builder instance.
I'm looking for a functionality that would do something like $modelInstance->invalidateCache()
and would cause that existing cache instance to be invalidated.
Unfortunately I have not digged deep in the source code here but I'm willing to take sometime to do it if its non-existant.
Upserts are two-in-one methods. Query Cache works only at the per-query level. 😀
The issue needs to be re-opened, as it's breaks updateOrCreate method.
We ran into this today, if you run updateOrCreate in a loop, the cache kicks in and caches the data, resulting in subsequent updates to fail from db insert.
This issue has been automatically closed because it has not had any recent activity. 😨
I'm trying to invalidate manually after an upsert as upsert is a Builder instance and would not trigger an "update" event for the model. Any workarounds?