php - Laravel Middleware Cache not working properly
Get the solution ↓↓↓Solution:
The behaviour of Cache::has method relies a lot in the actual backend you're using.
Try doing this:
public function handle($request, Closure $next)
{
$response = $next($request);
if(Cache::has(Config::get('ots.server_status_cache_name'))) {
return $response; // Exit method as soon as you can
}
$serverStatus = $this->checkServerStatus() ? 'up' : 'down';
Cache::put(Config::get('ots.server_status_cache_name'), $serverStatus, Config::get('ots.server_status_cache_time'));
return $response;
}
In that way you don't store a boolean in cache, but a string. Maybe this is not the solution, but will point you in the right direction.
Depending on the caching engine you use, you might want to start it in debug mode to see the connections and transactions being executed. For example, you can start memcached with -vv to see gets and sets, or you can connect to the Redis instance and execute MONITOR to see what your application does. This might help you spot the issue.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: method illuminate\database\eloquent\collection::paginate does not exist.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.