Laravel memcached errors after random time

Hello I am using memcached in laravel application 5.8.

After some time the error is:

production.ERROR: Invalid argument supplied for foreach()

Code in controller is:

$page = \Request::get('page', '0');

Cache::tags('posts')->remember('page-'.$page, 15, function(){
return Post::orderBy('created_at', 'desc')
->paginate(20);
});

$posts = Cache::tags('posts')->get('page-'.$page);

The error comes, because of the @foreach loop in the view.

When I get the error, I can fix it by restarting the server, but this is not really a good solution. How can I prevent this issue and still use memcached?

I am sure that it comes from the cache, because if I change the cache driver to array than the error is gone.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/384vpJz
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time