Sfoglia il codice sorgente

关于接口频繁的提示语

lizhen_gitee 1 giorno fa
parent
commit
e7c077e877

+ 1 - 1
app/Controller/Api/v1/PlayerController.php

@@ -40,7 +40,7 @@ class PlayerController extends AbstractController
             return AppResult::error('活动在'.site('subject_endtime').'就结束了');
         }
 
-        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->tryTimes(1, 2)) {
+        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->tryTimes(1, 3)) {
             return AppResult::error('操作太快了,休息一下吧');
         }
 

+ 1 - 1
app/Controller/Api/v1/QuestionController.php

@@ -94,7 +94,7 @@ class QuestionController extends AbstractController
             return AppResult::error('活动在'.site('subject_endtime').'就结束了');
         }
 
-        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->tryTimes(1, 2)) {
+        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->tryTimes(1, 3)) {
             return AppResult::error('操作太快了,休息一下吧');
         }
 

+ 2 - 2
app/Middleware/ApiAgent.php

@@ -70,8 +70,8 @@ class ApiAgent implements MiddlewareInterface
         LogUtil::info('请求参数', $action['controller'], $action['action'], $params);
 
         //接口限流,写到中间件中
-        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->requestLimit("{$action['controller']}/{$action['action']}", 1, 5000)) {
-            LogUtil::info('请求次数过多', $action['controller'], $action['action']);
+        if (!RedisUtil::getInstance(RedisKeyEnum::API_REQUEST_TRAFFIC)->requestLimit("{$action['controller']}/{$action['action']}", 1, 20000)) {
+            LogUtil::info('当前访问人数过多,请稍后再试', $action['controller'], $action['action']);
             return $this->response206();
         }