Last Updated: September 09, 2019
·
2.091K
· vohof

Easier cache for Laravel3

Gets an item from the cache, if not found cache the second param which expires till never.

Cache::sear('posts', function(){
    return Post::all();
});

Just thought people might want to know such easier method exists. Long cut:

Cache::get('posts', function(){
    $posts = Post::all();
    Cache::forever('posts', $posts);
    return $posts;
});

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside