Last active
May 8, 2024 12:42
-
-
Save winarcooo/e92016fea1a3f2852847700efa60e772 to your computer and use it in GitHub Desktop.
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
<?php | |
// check from cache, if not exist get using closure, | |
// then save to cache | |
$value = Cache::remember('users', $seconds, function () { | |
return DB::table('users')->get(); | |
}); | |
// wrap closure using transaction from DB facade | |
use Illuminate\Support\Facades\DB; | |
DB::transaction(function () { | |
DB::update('update users set votes = 1'); | |
DB::delete('delete from posts'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment