问题
Can anyone help me? I use redis cache. But I see same results on every pages when I use pagination. How can I fix it? Thanks.
回答1:
You should cache your results per page, with a key that is the current page.
$currentPage = request()->get('page',1);
$category = Cache::remember('sellcategory-' . $currentPage, 10, function(){
return DB::table('elans')->orderBy('updated_at', 'desc')->where(['derc' => 1,'elaninnovu' => 'Satılır'])->paginate(10);
});
来源:https://stackoverflow.com/questions/41976933/pagination-with-cache-in-laravel