Created
January 5, 2022 09:08
-
-
Save adinata-id/ae26cba146f54b061f738f81a0f9ef75 to your computer and use it in GitHub Desktop.
Contoh Cache Laravel
This file contains 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
if (Cache::has('article:slug:' . $slug)) { | |
$blog = Cache::get('article:slug:' . $slug); | |
} else { | |
$blog = Article::where('slug', $slug)->first(); | |
Cache::put('article:slug:' . $slug, $blog, $seconds = 600); | |
} | |
return $this->article = $blog; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment