Cache a single post? Cache and pagination?

Posted 1 year ago by ronon

I have two question related to Laravels Caching System.

First: Is it possible to Cache a single post?

class PostController{
    public function show(Post $post){
        // Post need to be cached before it arrives here?!?

On index I can do.

$posts = Cache:rembemer('posts', 60, function(){
    return Post::all();

Get all posts if they are not in cache.

Second: If you execute the code from above, can you still use pagination on posts, or do you have to cache every page from pagination?

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.