Support the ongoing development of Laravel.io →
posted 8 years ago
Eloquent
Last updated 2 years ago.
0

why not remove the product timestamps completely and rely on category timestamps?, since you're duplicating same values across tables.

0

@astroanu in laravel/eloquent each model uses the updated_at timestamps for multiple things, such as cache controll. When one child is changed, the cache of that child and the parent is removed. when building the new parant, the parent doesn't have to build all childs again, but only the ones changes, the rest it got from the cache to build the new parent and thats stored again. but when the parent category is changed, all child caches had to be removed, becouse of the changed categorie that had to be passed to the childs.

0

imo you should not rely on model's updated_at value to rebuild cache. when you update a category you should be able to simple destroy the cache for that category and the children by calling static method or you may use a model event to do that. I'm my knowledge Eloquent does not do this by default. unless you're calling remember method.

User::with('articles')->remember(5, 'user_articles')->get();

you can destroy the cache by calling

Cache::forget('user_articles');

How are you caching the items ?

0

im going to use russian doll caching from laracasts, thats using the updated_at ;) so thats why i talked about parent, child and siblings in the reply before.

Last updated 8 years ago.
0

i see, very tricky :(

0

why do you think thats tricky?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

BartHuis barthuis Joined 19 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.