Support the ongoing development of Laravel.io →
posted 10 years ago
Session Cache
Last updated 1 year ago.
0

Any feedback, thoughts, opinions, or trolling?

Last updated 1 year ago.
0
  1. 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.

  2. 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.

  1. 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

  2. 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.

Last updated 1 year ago.
0
  1. Cool. That's how I feel too.

  2. OK, thanks. I'm still curious though what the default is if you don't set it manually.

  3. Wow! Carbon is great! I just started a helper utility the other day to start doing this kind of stuff. Thanks for the link.

  4. 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!

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

neon5 neon5 Joined 21 Feb 2014

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.