You can use laravel caching to do this e.g. to cache your query every 15 minutes you can do the following
if (($myquery = Cache::get('myvars.cache')) === null)
{
$myquery = ......; //query to get the vars
Cache::put('myvars.cache', $myquery, 15);
}
Now if you want to cache you vars until they are changed the simply cache them forever and add a listener that clears the cache when you model is updated or saved!
if (($myquery = Cache::get('myvars.cache')) === null)
{
$myquery = ......; //query to get the vars
Cache::forever('myvars.cache', $myquery);
}
<?php
use Illuminate\Support\ServiceProvider;
class MyCacheServiceProvider extends ServiceProvider {
public function register()
{
$this->app['events']->listen('eloquent.saving: MyModel', function($model)
{
Cache::forget('myvars.cache');
});
}
}
)