每 60 秒限制 2 条通过
https://learnku.com/laravel/t/61700public function __construct(Model $dispatch, int $registerStatus, string $action) { $this->dispatch = $dispatch; $this->registerStatus = $registerStatus; $this->redisBlock = env('REDIS_BLOCK', 59); $this->redisAllow = env('REDIS_ALLOW', 2); $this->redisEvery = env('REDIS_EVERY', 60); $this->action = $action; } /** * @throws \Illuminate\Contracts\Redis\LimiterTimeoutException */ public function handle(): void { Redis::throttle('key')->block($this->redisBlock) ->allow($this->redisAllow) ->every($this->redisEvery) ->then(function () { $programSiteService = new ProgramSiteService(); $programSiteService->injectC2($this->dispatch, $this->registerStatus, $this->action); }, function () { Log::error('获取不了锁'); return $this->release(3); }); }