-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching paginated results #7
Comments
am in the same boat so i came up with a little somthing @inject('Model','App\Post')
@foreach ($posts as $post)
@cache("Posts/$post->id-".$Model->cacheDate($post->updated_at))
...
@endcache
@endforeach cacheDate is basically turning the value into timestamp, and we had to inject the model as the pagination returns an array so calling the method directly on $post wont work. public function cacheDate($value) {
return Carbon::parse($value)->timestamp;
} and now everything works as usual without changing anything in the original code 😉 |
Hi @ctf0, Thank you for your reply. This solution may work, but, instead of caching all the page (as I wanted), you are caching those items one by one. I finally ended up using redis to cache the collection and passing it to the view. It was a lot faster than using this package. Cheers, |
the problem with caching the whole page is when a fragment of that page is updated, u will have to regenerate the whole thing which is the exact opposite of what this package for. EDIT: |
Hi Jeffrey,
First of all, thank you very much for this package. I am a big fan of laracasts :)
I was trying to use the russian doll caching in a view with pagination, so to make it work I have to have this in my controller...
... and then pass it to the view. This way I can cache the results, but I am speding twice the memory. By the way, to allow
@cache
directive to cache collections I needed to run:Do you come up any idea how can I solve this?
Thanks in advance,
The text was updated successfully, but these errors were encountered: