Support the ongoing development of Laravel.io →
Configuration Database
Last updated 2 years ago.
0

We do this but we assign them in the config off the program to not have the DB called at all but we are going to change over to a cached DB call. Something like this will work - you can set the cache level. Wouldn't hold them in session

public function getSiteSettings() {

$siteid = Config::get('app.siteid');

$key = "db_settings"; $query = Cache::remember($key, 180, function() use ($siteid) { return YOUR_DB_QUERY });

return $query; }

$key is the cache key, remember for 180 minutes, use the siteid defined in your app environment file in the function. Anytime you want to get the settings for a calculation, etc just call this function. One DB call held in cache for as long as you set. Ideally you want to be running a fast cache like memcache/redis for this

0

Sign in to participate in this thread!

Eventy

Your banner here too?

dc83 dc83 Joined 13 May 2015

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.