Laravel's throttle middleware failure solution, laravelthrottle
This example describes how to solve Laravel's throttle middleware failure problem. We will share this with you for your reference. The details are as follows:
According to the official explanation, the Access frequency limit is very simple:
Route: get ('test', function () {return 'helle world';})-> middleware ('throttle ');
This is also true. make a judgment on the number of cache storage accesses.
Zizaco/entrust (a role-based permission management package) was used before, and CACHE_DRIVER = file in. env was changed to CACHE_DRIVER = array. So the problem arises. Laravel supports multiple cache drivers, such as File, Array, Db, and Redis. However, throttle seems to be effective only when a File driver is used.
My modifications are as follows:
Vendor/illuminate/cache/RateLimiter. php file
Public function _ construct (Cache $ cache) {$ this-> cache = $ cache;} public function _ construct () {$ this-> cache = app ('cache')-> driver ('file ');}
Change the above to the following. Throttle middleware also works.