Any feedback, thoughts, opinions, or trolling?
The default I find is a good choice. If you have a popular site your database can easily bog you down. You can also cache database results really easily. So while it could save some time, caching database results into a database seems a bit silly.
You set the lifetime for caching. You can even set it to "forever" so it never expires.
$expiresAt = Carbon::now()->addMinutes(10);
Cache::put('key', 'value', $expiresAt);
That saves the value in cache for 10 minutes.
Carbon is an extension of the DateTime class and it makes things a bit easier to use. Laravel uses Carbon in quite a few places. Carbon Github / Documentation
This really depends on a few factors all of which are up to you. If you cache a bunch items and the cache is being used all the time it will be faster to use an in-memory cache since you aren't reading / writing to the disk or database. When your application is moved to a VPS or dedicated server you might start looking into these other types of caches.
-- edit -- Markdown is changing the numbers on my points.
Cool. That's how I feel too.
OK, thanks. I'm still curious though what the default is if you don't set it manually.
Wow! Carbon is great! I just started a helper utility the other day to start doing this kind of stuff. Thanks for the link.
OK, I was kind of thinking that if the site ever grew enough to need a dedicated server that that is probably the time to consider a more robust cache. But it helps to get a second opinion.
Thanks!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community