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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community