Created
November 29, 2025 16:35
-
-
Save InnaTarasyan/987db600b9eb32e1643ae720f4ac21af to your computer and use it in GitHub Desktop.
cachef() — Cache & Return Closure Result in One Line
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
| // app/helpers.php | |
| if (! function_exists('cachef')) { | |
| function cachef($key, $seconds, Closure $callback) | |
| { | |
| return Cache::remember($key, $seconds, $callback); | |
| } | |
| } | |
| // Usage | |
| $users = cachef('active_users', 60, fn() => User::active()->get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment