With DB we have two actions - ADD and GET (INSERT and SELECT) In case if it's GET - get from cache. In case if it's ADD - add in DB, and fire an event to update the cache. You could talk about this method in your video. Great job!
@stefanbogdanovic5904 жыл бұрын
Awesome idea! Or just invalidate the cache after inserting new entity. But I think your idea is better :)
@impulserr4 жыл бұрын
Great idea so you don't need to care about how long to store, you can set forever and just update ;)
@eboubaker37223 жыл бұрын
You just answered the question I asked in my head after watching the video, this is an effective and brilliant technique.
@VictorSBFI2 жыл бұрын
An Observer should do that work.
@alexeykhachatryan12142 жыл бұрын
@@VictorSBFI should or can do that?
@paulfontaine78193 жыл бұрын
In case you want the cache to refresh every day, first call after midnight, just add the day in the cache key string. The key then changes every calender day. The old values will be cleared from the cache based on the provided timeout.
@robiparvez4 жыл бұрын
regarding database update issue, you can just add a check, where you can assign the cache value to a variable and add empty check. If empty, query from db else load the cache.
@Frank-ou2nr4 жыл бұрын
He was talking about the use-case where your cache does have data inside of it, but in the meantime your database was updated and the (now old) cache data is still stored in the file. Using what you suggest (checking if the cache has value) will not work in this case; the cache is not empty and thus your query will never execute and the old data will still be used by your application.
@oleoni14374 жыл бұрын
@@Frank-ou2nr what you mentioned is correct so one way to avoid that it would be to clear the cache every time the data get updated
@MrAhmedUA4 жыл бұрын
@@oleoni1437 yeah with some drivers which support cache tags you can for example if you have a cron that gets data from api daily you can do something like Cache::tags(['live-system'])->flush(); also maybe with laravel Eloquent Model upadating ~ deleting ~ creating events you can flush the cache too
@howtotech39564 жыл бұрын
321 likes and 0 dislikes. thats what called a quality channel.
@alnahian2003 Жыл бұрын
This video is sooo interesting that I frequently comeback rewatch it.
@videomania16353 жыл бұрын
your each and every video is great source of learning. Thanks...
@Shez-dc3fn4 жыл бұрын
the thing with caching i find is then i have to make sure that the cache is deleted on update or w/e... this can get messy if you have lots of cache for different things.. cache packages help but no package afaik has solved the problem of caching relation and then deleting them if relation data changes..
@educat6933 жыл бұрын
I think we can use eloquent model events to clear the related cache. It will be a one time effort for each of the model, after that it will be peaceful life. What is your opinion on that? Please let me know.
@apairca4 жыл бұрын
I think it's much better and recommended to use a Carbon instance instead of seconds for cache time to live.
@doremidon3 жыл бұрын
Why? Do you can explain?
@Maniac-00711 ай бұрын
@@doremidonreadability
@alexrusin4 жыл бұрын
Nice video. What if a query runs not 1 second, but 10 seconds. Every day there will be a user that will have to take it for the team. That person may not be very happy. Any cache warming strategies?
@PovilasKorop4 жыл бұрын
Hmm, good point. What about artisan command which runs once per night and refreshes the cache in the background? So no actual user would feel that 10 seconds.
@devanggandhi32663 жыл бұрын
Hello Sir, I need your suggestion. I am mainly working on API. so is it good to use cache in every api to speed up response ? what are the cons of using the cache ? if my data will update after 2 hours then can it handel it means does cache give the updated data also ?
@muhammadfatur84154 жыл бұрын
Very helpfull for me as begineer, thank's sir
@eid95524 жыл бұрын
Thank you for your nice tips. I have a question. What if the database is updated before the cache expires? Is there a way you suggest to get the latest data without loosing the performance?
@jesteriruka42153 жыл бұрын
You can run that query in parallel using crontab and artisan commands.
@НиколайШироков-т7л4 жыл бұрын
Thank you for your effort!
@RpExclusive3 жыл бұрын
may i know what is the browser extensions you used ?
@WireDroid3 жыл бұрын
Laravel debugbar
@ChangeYourLifeForever Жыл бұрын
THANK YOU GODFATHER
@ilmammourtada45384 жыл бұрын
Thank you for the video. May I ask what is that console you are using to show the query?
@PovilasKorop4 жыл бұрын
Laravel Debugbar, if that's what you meant by "console".
@santysasa122 жыл бұрын
Awesome tip! Thanks a lot
@ihtishamahmad652 жыл бұрын
Where does this cache save? in Browser or our Laravel Application?
@lifestyleblog63182 жыл бұрын
Did you used any extension for checking the Queries
@LaravelDaily2 жыл бұрын
Laravel Debugbar
@Lightnings1233 жыл бұрын
is it possible to cache on a resource::collection with pagination?
@oscarfelipeporras99734 жыл бұрын
amazing as always
@namazbekbekarysuly91124 жыл бұрын
It is great video. Let's say one applications needs to cache queries in multiple places. How can we regularly trigger caching in all places at particular time. Should we make a cron job that runs some command CacheApplicationCommand?
@Netherlands0314 жыл бұрын
I think you can indeed make a laravel scheduled task to your custom command, that uses Cache::put to make sure there's always a fresh cache and users never have to hit the db (for some queries), and then run that command as well when something in the db gets updated and you need to refresh the cache
@lukmanulhakim88413 жыл бұрын
Are it's save for used on production sir?
@amitleuva87392 жыл бұрын
can a query be cached using redis?
@javerleo2 жыл бұрын
Excellent explanation! Thanks. Does it work with Eloquent models in Livewire components?
@LaravelDaily2 жыл бұрын
Yes, same
@lifestyleblog63182 жыл бұрын
can i used file cached in laravel ?
@MzN...3 ай бұрын
Thx
@tienphungkhac1491 Жыл бұрын
What is the extension you just using in the browser?
@LaravelDaily Жыл бұрын
composer require barryvdh/laravel-debugbar
@tienphungkhac1491 Жыл бұрын
@@LaravelDaily thanks
@danorex91004 жыл бұрын
Thank you for video :)
@mreduar4 жыл бұрын
I have a website that updates the database every time the user downloads a document, that is, I keep track of the downloads of that document. When the database is updated, the cache is lost in the whole app only because of that number update. Any suggestion for this situation?
@PovilasKorop4 жыл бұрын
You're probably caching the wrong thing, then. Instead of having one cache query for the whole app, maybe you should cache some specific things that wouldn't be re-cached after one number update. Or, maybe, you should be ok with holding the cache for a little more and not refresh it after EVERY download, just maybe once per hour or so.
@santiagotv60953 жыл бұрын
@Laravel Daily what is the extension yo used to view the query, timeline and etc. like 0:20
@WireDroid3 жыл бұрын
Laravel debugbar
@anasbousrateh95374 жыл бұрын
Thank you for this amazing video, it's really helpful
@music-masala-77893 жыл бұрын
if we have dynamic user Id and other field is user IP , this cache is usefull or not ?
@LaravelDaily3 жыл бұрын
You need to measure it.
@EugeneChe-814 жыл бұрын
Круто) Спасибо)
@fire23hummer Жыл бұрын
Perfectooo :)
@ricko133 жыл бұрын
This is an excelent feature if you know how and when to use it, I did it wrong and I receive an email from my server provider telling me that my VPS reached a high I/O and so a shutdown was required It was triggered cuz I was using the "file" cache driver in Laravel #LessonLearned
@fahrim27294 жыл бұрын
Best sir
@shuvoahmed52173 жыл бұрын
Make a video about laravel horizon with php redis. Its not working on windows
@kid_rz4 жыл бұрын
what aboout paginate data?
@mudzarao3 жыл бұрын
Same question. Have you tried playing around it? If yes, did you manage to find a solution for it?
@DanZL14 жыл бұрын
Thank you for the great videos you make. Since you are knowledgeable on Laravel, perhaps you can share your perspective on the following. While speaking to a developer about Laravel and converting our WP website to Laravel, their reply was that Laravel is still unstable and has releases every months or so. What's your response to this?
@PovilasKorop4 жыл бұрын
I already replied to you, on another video, read the comment here: kzbin.info/www/bejne/qXLNfYV7gtdgb80&lc=UgxfpVnVL60BIdxtnd54AaABAg
@SKIDKOVOZ2 жыл бұрын
Hi I am from Ukraine. I have a problem, I make link shortener on laravel - with counter by clicks on short link, and i have a trouble with add link to cashe and counter clicks on it - correctly, may I ask about some lesson from you about this, or maybe paid lessons so that you help me learn how to do what I want? I am not programmer i try make some functions for myself.
@DBRSAstonMartin2 жыл бұрын
How would you refresh the cache say that book title was updated in the database?
@raminjavi1612 жыл бұрын
You are such a perfect teacher. I love the way you teach; Your lessons are short, real, and useful. Thank you
@gado_official4 жыл бұрын
I wonder if using pagination is it method would works or not?
@khizer35282 жыл бұрын
Thanks for the useful information .
@isaaclovera89753 жыл бұрын
How to the cache in LiteSpeed?
@mohidden4 жыл бұрын
best of the best laravel tutos.sup of laravel thanks sir.