Last active
April 22, 2019 02:40
-
-
Save jpalala/0e3facc254465d2019af22026304b71a to your computer and use it in GitHub Desktop.
caching in laravel eloquent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* timeout = seconds */ | |
function cacheDB(array $tags, $depKey, $sql, $timeout = 300) { | |
$data = DB::select(DB::raw($sql)); | |
return Cache::tags($tags)->put($depKey, $sql); | |
//remember($depKey, $timeout, function() use($sql) { | |
// Some join query that will return all Managers from selected Department | |
return DB::select(DB::raw($sql)); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment